Class: Engine
- Inherits:
-
Object
- Object
- Engine
- Defined in:
- lib/triggerable/engine.rb
Class Method Summary collapse
- .automation(model, options, block) ⇒ Object
- .clear ⇒ Object
- .run_automations(interval) ⇒ Object
- .trigger(model, options, block) ⇒ Object
- .triggers_for(obj, callback) ⇒ Object
Class Method Details
.automation(model, options, block) ⇒ Object
11 12 13 |
# File 'lib/triggerable/engine.rb', line 11 def self.automation model, , block self.automations << Rules::Automation.new(model, , block) end |
.clear ⇒ Object
24 25 26 27 |
# File 'lib/triggerable/engine.rb', line 24 def self.clear self.triggers = [] self.automations = [] end |
.run_automations(interval) ⇒ Object
19 20 21 22 |
# File 'lib/triggerable/engine.rb', line 19 def self.run_automations interval self.interval = interval automations.each(&:execute!) end |
.trigger(model, options, block) ⇒ Object
7 8 9 |
# File 'lib/triggerable/engine.rb', line 7 def self.trigger model, , block self.triggers << Rules::Trigger.new(model, , block) end |
.triggers_for(obj, callback) ⇒ Object
15 16 17 |
# File 'lib/triggerable/engine.rb', line 15 def self.triggers_for obj, callback triggers.select{|t| obj.is_a?(t.model) && t.callback == callback } end |