Class: Triggerable::Rules::Trigger
- Defined in:
- lib/triggerable/rules/trigger.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
Attributes inherited from Rule
#actions, #condition, #model, #name
Instance Method Summary collapse
- #execute!(object) ⇒ Object
-
#initialize(model, options, block) ⇒ Trigger
constructor
A new instance of Trigger.
Constructor Details
#initialize(model, options, block) ⇒ Trigger
Returns a new instance of Trigger.
6 7 8 9 |
# File 'lib/triggerable/rules/trigger.rb', line 6 def initialize model, , block super @callback = [:on] end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
4 5 6 |
# File 'lib/triggerable/rules/trigger.rb', line 4 def callback @callback end |
Instance Method Details
#execute!(object) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/triggerable/rules/trigger.rb', line 11 def execute! object return unless condition.true_for?(object) actions.each do |action| begin action.run_for!(object, name) rescue Exception => ex Triggerable::Engine.log(:error, "#{desc} failed with exception #{ex}") end end end |