Module: CanTango::Ability::Helper::Engine

Defined in:
lib/cantango/ability/helper/engine.rb

Instance Method Summary collapse

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

#enginesObject



24
25
26
# File 'lib/cantango/ability/helper/engine.rb', line 24

def engines
  CanTango.config.engines
end

#engines_on?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


16
17
18
# File 'lib/cantango/ability/helper/engine.rb', line 16

def opts_engines_off?
  options[:engines] == :off
end