Class: Octiron::World::AutoTransmogrifyDelegator Private
- Inherits:
-
TransmogrifierRegistrator
- Object
- TransmogrifierRegistrator
- Octiron::World::AutoTransmogrifyDelegator
- Defined in:
- lib/octiron/world.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Delegator for the autotransmogiry(FROM).to TO syntax
Instance Method Summary collapse
-
#initialize(from, verify_results = false) ⇒ AutoTransmogrifyDelegator
constructor
private
A new instance of AutoTransmogrifyDelegator.
- #to(to, transmogrifier_object = nil, &transmogrifier_proc) ⇒ Object private
Constructor Details
#initialize(from, verify_results = false) ⇒ AutoTransmogrifyDelegator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of AutoTransmogrifyDelegator.
74 75 76 77 |
# File 'lib/octiron/world.rb', line 74 def initialize(from, verify_results = false) @from = from @verify_results = verify_results end |
Instance Method Details
#to(to, transmogrifier_object = nil, &transmogrifier_proc) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/octiron/world.rb', line 79 def to(to, transmogrifier_object = nil, &transmogrifier_proc) # First register the transmogrifier super # Then create an event handler that chains the transmogrify step with a # publish step. ::Octiron::World.event_bus.subscribe(@from) do |event| # By default, we don't want to raise errors if the transmogrifier # returns nil. Still, raising should be activated optionally. new_ev = ::Octiron::World.transmogrifier_registry.transmogrify( event, to, @verify_results ) ::Octiron::World.event_bus.publish(new_ev) end end |