Class: Houston::Triggers
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Houston::Triggers
- Defined in:
- lib/houston/boot/triggers.rb
Instance Attribute Summary collapse
-
#async ⇒ Object
Returns the value of attribute async.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #build(method_name, value, action, params, persistent_trigger_id: nil) ⇒ Object
- #delete(trigger) ⇒ Object
- #every(value, action, params = {}) ⇒ Object
-
#initialize(config) ⇒ Triggers
constructor
A new instance of Triggers.
- #on(event, action, params = {}) ⇒ Object
- #push(trigger) ⇒ Object
Constructor Details
#initialize(config) ⇒ Triggers
Returns a new instance of Triggers.
11 12 13 14 15 |
# File 'lib/houston/boot/triggers.rb', line 11 def initialize(config) @config = config @async = true super Concurrent::Array.new end |
Instance Attribute Details
#async ⇒ Object
Returns the value of attribute async.
9 10 11 |
# File 'lib/houston/boot/triggers.rb', line 9 def async @async end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/houston/boot/triggers.rb', line 8 def config @config end |
Instance Method Details
#build(method_name, value, action, params, persistent_trigger_id: nil) ⇒ Object
26 27 28 |
# File 'lib/houston/boot/triggers.rb', line 26 def build(method_name, value, action, params, persistent_trigger_id: nil) Trigger.new(self, method_name, value, action, params, persistent_trigger_id) end |
#delete(trigger) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/houston/boot/triggers.rb', line 37 def delete(trigger) i = find_index(trigger) return unless i trigger = self[i] trigger.unregister! delete_at i end |
#every(value, action, params = {}) ⇒ Object
18 19 20 |
# File 'lib/houston/boot/triggers.rb', line 18 def every(value, action, params={}) push build(:every, value, action, params) end |
#on(event, action, params = {}) ⇒ Object
22 23 24 |
# File 'lib/houston/boot/triggers.rb', line 22 def on(event, action, params={}) push build(:on, event, action, params) end |
#push(trigger) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/houston/boot/triggers.rb', line 30 def push(trigger) raise DuplicateTriggerError, "That exact trigger has already been defined" if member?(trigger) super trigger trigger.register! trigger end |