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.
298 299 300 |
# File 'lib/roby/event_generator.rb', line 298 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.
296 297 298 |
# File 'lib/roby/event_generator.rb', line 296 def block @block end |
Instance Method Details
#==(other) ⇒ Object
330 331 332 333 334 |
# File 'lib/roby/event_generator.rb', line 330 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
321 322 323 324 325 326 327 328 |
# File 'lib/roby/event_generator.rb', line 321 def mode = if copy_on_replace? then :copy else :drop end { on_replace: mode, once: once? } end |
#call(*args) ⇒ Object
302 303 304 |
# File 'lib/roby/event_generator.rb', line 302 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.
311 312 313 |
# File 'lib/roby/event_generator.rb', line 311 def copy_on_replace? !!@copy_on_replace end |
#once? ⇒ Boolean
True if this event handler should be called only once
316 317 318 |
# File 'lib/roby/event_generator.rb', line 316 def once? !!@once end |