-
Notifications
You must be signed in to change notification settings - Fork 5
Anatomy of a Permit
kristianmandrup edited this page Nov 25, 2011
·
1 revision
A Permit has a module for each kind of execution mode it can be executed in. Each execution module has a method #execute
which contains the statements that produce the CanCan rules, typically #can
and #cannot
, but also CanTango wrappers on top of these.
Permit example:
class AdminRolePermit < CanTango::Permit::Role
# always executed
module Default
def execute
# can/cannot statements
end
end
# executed in :cache mode only
module Cache
def execute
# can/cannot statements
end
end
# executed in :no_cache mode only
module NoCache
def execute
# can/cannot statements
end
end
end