liam-m / flippd

A lightweight VLE for the "flipped classroom"
1 stars 0 forks source link

Moved JSON Parsing, added item assertion methods #44

Open Lixquid opened 8 years ago

Lixquid commented 8 years ago

First, moved JSON Parsing to a new helpers directory, which is automatically loaded before models.

Second, added new must_be_a and must_be_authenticated methods available for routes. These can be used instead of pass unless @item["type"] == clauses for more readable pre-conditions. An example:

post '/phases/:title/:slug' do
  must_be_a :video
  must_be_authenticated

instead of

post '/phases/:title/:slug' do
  pass unless @item
  pass unless @item["type"] == :video
  pass unless @user