Yet another model framework
get, set
.id
constructor, initialize
TODO:
isValid, validate
has, clone, toJSON
keys,values,pairs,invert,pick,omit
url
model.get_singular() # Default: snake_case(class name)
model.get_plural() # Default: singular + "s"
class Goose
@plural = "geese"
All key parts are joined by ":".
[plural, id] -> JSON
TODO:
[plural, id, association, other_id] -> empty
[singular + "_revs", id, rev_id] -> JSON
model.path() → "/#{plural}/#{id}"
Model.init(app) # checks app.dir/models/*, sets the following
Model.classes # {'FooBar': FooBar}
Model.classes_by_plural # {'foo_bars': FooBar}
Model.middleware()
If all of
req.methodisGETreq.paramscontains anidmatching/^[a-zA-Z0-9_-]+$/req.urlstarts with/plural/for a known model
...then fetch the model.
If the model exists, set req.singular to the model.
If not, res.render '404' and don't call next().
