Class: Roby::EventGenerator::EventHandler
- Defined in:
- lib/roby/event_generator.rb
Overview
Class used to register event handler blocks along with their options
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#as_options ⇒ Object
Generates an option hash valid for EventGenerator#on.
- #call(*args) ⇒ Object
-
#copy_on_replace? ⇒ Boolean
True if this event handler should be moved to the new task in case of replacements.
-
#initialize(block, copy_on_replace, once) ⇒ EventHandler
constructor
A new instance of EventHandler.
-
#once? ⇒ Boolean
True if this event handler should be called only once.
Constructor Details
#initialize(block, copy_on_replace, once) ⇒ EventHandler
Returns a new instance of EventHandler.
287 288 289 |
# File 'lib/roby/event_generator.rb', line 287 def initialize(block, copy_on_replace, once) @block, @copy_on_replace, @once = block, copy_on_replace, once end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
285 286 287 |
# File 'lib/roby/event_generator.rb', line 285 def block @block end |
Instance Method Details
#==(other) ⇒ Object
314 315 316 317 318 |
# File 'lib/roby/event_generator.rb', line 314 def ==(other) @copy_on_replace == other.copy_on_replace? && @once == other.once? && block == other.block end |
#as_options ⇒ Object
Generates an option hash valid for EventGenerator#on
306 307 308 309 310 311 312 |
# File 'lib/roby/event_generator.rb', line 306 def mode = if copy_on_replace? then :copy else :drop end { on_replace: mode, once: once? } end |
#call(*args) ⇒ Object
291 292 293 |
# File 'lib/roby/event_generator.rb', line 291 def call(*args) block.call(*args) end |
#copy_on_replace? ⇒ Boolean
True if this event handler should be moved to the new task in case of replacements
The default in Task#on is false for non-abstract tasks and true for abstract tasks.
300 |
# File 'lib/roby/event_generator.rb', line 300 def copy_on_replace?; !!@copy_on_replace end |
#once? ⇒ Boolean
True if this event handler should be called only once
303 |
# File 'lib/roby/event_generator.rb', line 303 def once?; !!@once end |