Advertisement
Guest User

Untitled

a guest
Nov 7th, 2012
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 1.16 KB | None | 0 0
  1. @Controller("thing")
  2. @VirtualAction("new", "create", Protect(Role("admin")))
  3. @VirtualAction("edit", "update", Protect(OwnerRelation))
  4. class ThingController : ApplicationController {
  5.  
  6.     @Action
  7.     @Protect(Role("admin"))
  8.     void create ( Request req, Response res ) {...}
  9.  
  10.     @Action
  11.     void index ( Request req, Response res ) {...}
  12.  
  13.     @Action
  14.     @Protect(Role("member"))
  15.     void show ( Request req, Response res ) {...}
  16.  
  17.     @Action
  18.     @Protect(OwnerRelation)
  19.     void update ( Request req, Response res ) {...}
  20.  
  21.     @Action("delete")
  22.     @Protect(Role("admin"))
  23.     void remove ( Request req, Response res ) {...}
  24.  
  25. }
  26.  
  27. @Model("thing")
  28. @ForbidMassAssignment
  29. class Thing : Model {
  30.  
  31.     @Attr
  32.     @Shallow
  33.     @Validate(Present, Unique, Length("<=", 128))
  34.     A!string name;
  35.    
  36.     @Attr
  37.     @Shallow
  38.     @Validate(Length("[]", 16, 256))
  39.     A!string description;
  40.  
  41.     @Attr(BelongsTo, User)
  42.     @Shallow
  43.     @Validate(Present)
  44.     A!User user;
  45.  
  46.     @Attr(HasMany, Tag, Through(Tagging))
  47.     @Validate(NoDuplicate)
  48.     A!(Tagging[]) tags;
  49.  
  50.     @Attr
  51.     @Validate(Present)
  52.     A!ulong size;
  53.  
  54.     @Attr
  55.     @Validate(Present)
  56.     A!ulong weight;
  57.  
  58.     @property
  59.     ulong ratio () {...}
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement