Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Nov 7th, 2012  |  syntax: D  |  size: 1.16 KB  |  hits: 99  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }