Class: CanTango::Ability::Executor::Modal
- Extended by:
- ClassMethods
- Defined in:
- lib/cantango/ability/executor/modal.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary
Attributes inherited from Base
#ability, #executed, #modes, #options
Attributes included from Helpers::Debug
Attributes inherited from Base
Instance Method Summary collapse
- #calculate_rules ⇒ Object
- #execute ⇒ Object
- #finder ⇒ Object
-
#initialize(ability, modes, options = {}) ⇒ Modal
constructor
A new instance of Modal.
Methods included from ClassMethods
Methods inherited from Base
Methods included from Builder
Methods included from Callbacks
#handle_callbacks, included, #within_callbacks
Methods included from Helpers::Debug
Methods included from CanTango::Ability::Executor
Methods included from Rules
#clear_rules!, #default_rules, #normalize_rules!, #rules
Methods inherited from Base
Constructor Details
#initialize(ability, modes, options = {}) ⇒ Modal
Returns a new instance of Modal.
3 4 5 6 7 |
# File 'lib/cantango/ability/executor/modal.rb', line 3 def initialize ability, modes, = {} super ability, extract_modes modes execute end |
Instance Method Details
#calculate_rules ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/cantango/ability/executor/modal.rb', line 16 def calculate_rules @rules = modes.inject([]) do |result, mode| result = result + modal_rules(mode) result end normalize_rules! end |
#execute ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cantango/ability/executor/modal.rb', line 24 def execute return if executed? clear_rules! calculate_rules rescue Exception => e debug e. ensure @executed = true rules end |