Module: CanTango::Ability::Helper::Engine
- Defined in:
- lib/cantango/ability/helper/engine.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
10 11 12 13 14 |
# File 'lib/cantango/ability/helper/engine.rb', line 10 def each_engine &block engines.execution_order.each do |name| yield engines.registered[name] if engines.active? name end end |
#engines ⇒ Object
24 25 26 |
# File 'lib/cantango/ability/helper/engine.rb', line 24 def engines CanTango.config.engines end |
#engines_on? ⇒ Boolean
20 21 22 |
# File 'lib/cantango/ability/helper/engine.rb', line 20 def engines_on? CanTango.config.engines.any?(:on) && !opts_engines_off? end |
#execute_engines! ⇒ Object
3 4 5 6 7 8 |
# File 'lib/cantango/ability/helper/engine.rb', line 3 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
16 17 18 |
# File 'lib/cantango/ability/helper/engine.rb', line 16 def opts_engines_off? [:engines] == :off end |