
Untitled
By: a guest on
Nov 7th, 2012 | syntax:
D | size: 1.25 KB | hits: 80 | expires: Never
@[Controller("thing")]
@[VirtualAction("new", "create", Protect(Role("admin")))]
@[VirtualAction("edit", "update", Protect(OwnerRelation))]
class ThingController : ApplicationController {
@[Action, Protect(Role("admin"))]
void create ( Request req, Response res ) {...}
@[Action]
void index ( Request req, Response res ) {...}
@[Action, Protect(Role("member"))]
void show ( Request req, Response res ) {...}
@[Action, Protect(OwnerRelation)]
void update ( Request req, Response res ) {...}
@[Action("delete"), Protect(Role("admin"))]
void remove ( Request req, Response res ) {...}
}
@[Model("thing")]
@[ForbidMassAssignment]
class Thing : Model {
@[Attr, Shallow]
@[Validate( Present, Unique, Length("<=", 128) )]
A!string name;
@[Attr, Shallow]
@[Validate( Length("[]", 16, 256) )]
A!string description;
@[Attr(BelongsTo, User), Shallow]
@[Validate( Present )]
A!User user;
@[Attr(HasMany, Tag, Through(Tagging))]
@[Validate( NoDuplicate )]
A!(Tagging[]) tags;
@[Attr]
@[Validate( Present )]
A!ulong size;
@[Attr]
@[Validate( Present )]
A!ulong weight;
@property
ulong ratio () {...}
}