Module: CanTango::Permits::Permit::Execute
- Included in:
- CanTango::Permits::Permit
- Defined in:
- lib/cantango/permits/permit/execute.rb
Instance Method Summary collapse
- #cached_rules ⇒ Object
- #dynamic_rules ⇒ Object
-
#execute ⇒ Object
executes the permit.
-
#executor ⇒ Object
return the executor used to execute the permit.
- #include_cached ⇒ Object
- #include_non_cached ⇒ Object
- #non_cached_rules ⇒ Object
-
#permit? ⇒ Boolean
In a specific Role based Permit you can use def permit? user, options = {} return if !super(user, :in_role) …
-
#permit_rules ⇒ Object
This method will contain the actual rules can be implemented in the subclass.
- #run_rule_methods ⇒ Object
- #static_rules ⇒ Object
Instance Method Details
#cached_rules ⇒ Object
43 44 45 |
# File 'lib/cantango/permits/permit/execute.rb', line 43 def cached_rules include_cached if defined?(self.class::Cached) end |
#dynamic_rules ⇒ Object
74 75 |
# File 'lib/cantango/permits/permit/execute.rb', line 74 def dynamic_rules end |
#execute ⇒ Object
executes the permit
6 7 8 9 10 11 |
# File 'lib/cantango/permits/permit/execute.rb', line 6 def execute return if disabled? debug "Execute Permit: #{self}" executor.execute! ability_sync! end |
#executor ⇒ Object
return the executor used to execute the permit
56 57 58 59 60 61 62 63 |
# File 'lib/cantango/permits/permit/execute.rb', line 56 def executor @executor ||= case self.class.name when /System/ then CanTango::PermitEngine::Executor::System.new self else CanTango::PermitEngine::Executor::Base.new self end end |
#include_cached ⇒ Object
51 52 53 |
# File 'lib/cantango/permits/permit/execute.rb', line 51 def include_cached self.class.send :include, self.class::Cached end |
#include_non_cached ⇒ Object
47 48 49 |
# File 'lib/cantango/permits/permit/execute.rb', line 47 def include_non_cached self.class.send :include, self.class::NonCached end |
#non_cached_rules ⇒ Object
39 40 41 |
# File 'lib/cantango/permits/permit/execute.rb', line 39 def non_cached_rules include_non_cached if defined?(self.class::NonCached) end |
#permit? ⇒ Boolean
In a specific Role based Permit you can use
def permit? user, options = {}
return if !super(user, :in_role)
... permission logic follows
This will call the Permit::Base#permit? instance method (the method below) It will only return true if the user matches the role of the Permit class and the options passed in is set to :in_role
If these confitions are not met, it will return false and thus the outer permit will not run the permission logic to follow
Normally super for #permit? should not be called except for this case, or if subclassing another Permit than Permit::Base
28 29 30 31 |
# File 'lib/cantango/permits/permit/execute.rb', line 28 def permit? cached? ? cached_rules : non_cached_rules run_rule_methods end |
#permit_rules ⇒ Object
This method will contain the actual rules can be implemented in the subclass
68 69 |
# File 'lib/cantango/permits/permit/execute.rb', line 68 def permit_rules end |
#run_rule_methods ⇒ Object
33 34 35 36 37 |
# File 'lib/cantango/permits/permit/execute.rb', line 33 def run_rule_methods static_rules permit_rules dynamic_rules end |
#static_rules ⇒ Object
71 72 |
# File 'lib/cantango/permits/permit/execute.rb', line 71 def static_rules end |