Class: Rules::Trigger

Inherits:
Rule
  • Object
show all
Defined in:
lib/triggerable/rules/trigger.rb

Instance Attribute Summary collapse

Attributes inherited from Rule

#actions, #condition, #model

Instance Method Summary collapse

Constructor Details

#initialize(model, options, block) ⇒ Trigger

Returns a new instance of Trigger.



5
6
7
8
# File 'lib/triggerable/rules/trigger.rb', line 5

def initialize model, options, block
  super
  @callback  = options[:on]
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



3
4
5
# File 'lib/triggerable/rules/trigger.rb', line 3

def callback
  @callback
end

Instance Method Details

#execute!(object) ⇒ Object



10
11
12
# File 'lib/triggerable/rules/trigger.rb', line 10

def execute! object
  actions.each {|a| a.run_for!(object)} if condition.true_for?(object)
end