User Defined Attributes
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Tue Nov 6 13:03:55 PST 2012
Just thinking out loud...
##################################################
[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 () {...}
}
##################################################
My mind reels...
-- Chris Nicholson-Sauls
More information about the Digitalmars-d-announce
mailing list