Class: Ductr::Trigger
- Inherits:
-
Object
- Object
- Ductr::Trigger
- Defined in:
- lib/ductr/trigger.rb
Overview
The base class for any trigger, can be initialized by passing it its adapter name if any. A trigger must implement the #add method which is called for each trigger declaration. Depending on what your trigger do, you may have to implement the #start and #stop methods. #start is called when the scheduler relying on the trigger is started. #stop does the opposite: it is called when the scheduler relying on the trigger is stopped.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
-
#add(_method, _options) ⇒ void
Adds a new trigger, called by a scheduler when a trigger is declared.
-
#initialize(adapter = nil) ⇒ Trigger
constructor
Creates a new trigger instance, called by the scheduler.
-
#start ⇒ void
Called when the scheduler relying on the trigger is started.
-
#stop ⇒ void
Called when the scheduler relying on the trigger is stopped.
Constructor Details
#initialize(adapter = nil) ⇒ Trigger
Creates a new trigger instance, called by the scheduler.
19 20 21 |
# File 'lib/ductr/trigger.rb', line 19 def initialize(adapter = nil) @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
12 13 14 |
# File 'lib/ductr/trigger.rb', line 12 def adapter @adapter end |
Instance Method Details
#add(_method, _options) ⇒ void
This method returns an undefined value.
Adds a new trigger, called by a scheduler when a trigger is declared.
31 32 33 |
# File 'lib/ductr/trigger.rb', line 31 def add(_method, ) raise NotImplementedError, "A trigger must implement the #add method" end |
#start ⇒ void
This method returns an undefined value.
Called when the scheduler relying on the trigger is started.
40 |
# File 'lib/ductr/trigger.rb', line 40 def start; end |
#stop ⇒ void
This method returns an undefined value.
Called when the scheduler relying on the trigger is stopped.
47 |
# File 'lib/ductr/trigger.rb', line 47 def stop; end |