Module: Roby::Transaction::EventGeneratorProxy
- Defined in:
- lib/roby/transaction/event_generator_proxy.rb
Instance Method Summary collapse
- #commit_transaction ⇒ Object
- #initialize_replacement(event, &block) ⇒ Object
- #setup_proxy(object, plan) ⇒ Object
Instance Method Details
#commit_transaction ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/roby/transaction/event_generator_proxy.rb', line 48 def commit_transaction super handlers.each { |h| __getobj__.on(**h., &h.block) } unreachable_handlers.each do |cancel, h| on_replace = if h.copy_on_replace? then :copy else :drop end __getobj__.if_unreachable( cancel_at_emission: cancel, on_replace: on_replace, &h.block) end end |
#initialize_replacement(event, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/roby/transaction/event_generator_proxy.rb', line 17 def initialize_replacement(event, &block) # Apply recursively all event handlers of this (proxied) event to # the new event # # We have to look at all levels as, in transactions, the "handlers" # set only contains new event handlers real_object = self while real_object.transaction_proxy? real_object = real_object.__getobj__ real_object.handlers.each do |h| if h.copy_on_replace? event ||= yield event.on(**h., &h.block) end end real_object.unreachable_handlers.each do |cancel, h| if h.copy_on_replace? event ||= yield event.if_unreachable(cancel_at_emission: cancel, on_replace: :copy, &h.block) end end end if event super(event) else super(nil, &block) end end |
#setup_proxy(object, plan) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/roby/transaction/event_generator_proxy.rb', line 8 def setup_proxy(object, plan) super(object, plan) @handlers.clear @unreachable_handlers.clear if object.controlable? @command = method(:emit) end end |