Module: CanTango::Ability::EngineHelpers
- Included in:
- CanTango::Ability
- Defined in:
- lib/cantango/ability/engine_helpers.rb
Instance Method Summary collapse
- #each_engine(&block) ⇒ Object
- #engines ⇒ Object
- #engines_on? ⇒ Boolean
- #execute_engines! ⇒ Object
- #opts_engines_off? ⇒ Boolean
Instance Method Details
#each_engine(&block) ⇒ Object
11 12 13 14 15 |
# File 'lib/cantango/ability/engine_helpers.rb', line 11 def each_engine &block engines.execution_order.each do |name| yield engines.registered[name] if engines.active? name end end |
#engines ⇒ Object
25 26 27 |
# File 'lib/cantango/ability/engine_helpers.rb', line 25 def engines CanTango.config.engines end |
#engines_on? ⇒ Boolean
21 22 23 |
# File 'lib/cantango/ability/engine_helpers.rb', line 21 def engines_on? CanTango.config.engines.any?(:on) && !opts_engines_off? end |
#execute_engines! ⇒ Object
4 5 6 7 8 9 |
# File 'lib/cantango/ability/engine_helpers.rb', line 4 def execute_engines! each_engine do |engine| engine_rules = engine.new(self).execute! if engine @rules << engine_rules if !engine_rules.blank? end end |
#opts_engines_off? ⇒ Boolean
17 18 19 |
# File 'lib/cantango/ability/engine_helpers.rb', line 17 def opts_engines_off? [:engines] == :off end |