Class: OFlow::Actors::Trigger
- Inherits:
-
OFlow::Actor
- Object
- OFlow::Actor
- OFlow::Actors::Trigger
- Defined in:
- lib/oflow/actors/trigger.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
The number of time the timer has fired or shipped.
-
#label ⇒ Object
readonly
Label for the Tracker is used and for trigger content.
-
#with_tracker ⇒ Object
readonly
Boolean flag indicating a tracker should be added to the trigger content if true.
Attributes inherited from OFlow::Actor
Instance Method Summary collapse
-
#initialize(task, options) ⇒ Trigger
constructor
A new instance of Trigger.
- #new_event ⇒ Object
- #set_label(v) ⇒ Object
- #set_options(options) ⇒ Object
- #set_with_tracker(v) ⇒ Object
Methods inherited from OFlow::Actor
#busy?, #inputs, #options, #outputs, #perform, #set_option, #with_own_thread
Constructor Details
#initialize(task, options) ⇒ Trigger
Returns a new instance of Trigger.
15 16 17 18 19 |
# File 'lib/oflow/actors/trigger.rb', line 15 def initialize(task, ) super @count = 0 () end |
Instance Attribute Details
#count ⇒ Object (readonly)
The number of time the timer has fired or shipped.
13 14 15 |
# File 'lib/oflow/actors/trigger.rb', line 13 def count @count end |
#label ⇒ Object (readonly)
Label for the Tracker is used and for trigger content.
8 9 10 |
# File 'lib/oflow/actors/trigger.rb', line 8 def label @label end |
#with_tracker ⇒ Object (readonly)
Boolean flag indicating a tracker should be added to the trigger content if true.
11 12 13 |
# File 'lib/oflow/actors/trigger.rb', line 11 def with_tracker @with_tracker end |
Instance Method Details
#new_event ⇒ Object
21 22 23 24 |
# File 'lib/oflow/actors/trigger.rb', line 21 def new_event() tracker = @with_tracker ? Tracker.create(@label) : nil Box.new({ source: task.full_name, label: @label, timestamp: Time.now.utc() }, tracker) end |
#set_label(v) ⇒ Object
31 32 33 34 |
# File 'lib/oflow/actors/trigger.rb', line 31 def set_label(v) v = v.to_s unless v.nil? @label = v end |
#set_options(options) ⇒ Object
26 27 28 29 |
# File 'lib/oflow/actors/trigger.rb', line 26 def () set_with_tracker([:with_tracker]) @label = [:label].to_s end |
#set_with_tracker(v) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/oflow/actors/trigger.rb', line 36 def set_with_tracker(v) v = false if v.nil? unless true == v || false == v raise ConfigError.new("Expected with_tracker to be a boolean, not a #{v.class}.") end @with_tracker = v end |