Module: Octiron::World
- Extended by:
- ClassMethods
- Defined in:
- lib/octiron/world.rb
Overview
World module, putting together the event bus and transmogrifier registry with easy access functions.
Defined Under Namespace
Modules: ClassMethods Classes: AutoTransmogrifyDelegator, TransmogrifierRegistrator, TransmogrifyDelegator
Instance Method Summary collapse
-
#autotransmogrify(from, options = {}) ⇒ Object
Automatically transmogrify one event type to another, and publish the result.
-
#on_event(event_id, handler_object = nil, handler_class = ::Octiron::Events::Bus::DEFAULT_CLASS, &handler_proc) ⇒ Object
Subscribe an event handler to an event with the singleton event bus.
-
#on_transmogrify(from) ⇒ Object
Register a transmogrifier with the singleton transmogrifier registry.
-
#publish(event) ⇒ Object
Publish an event on the singleton event bus.
-
#transmogrify(from) ⇒ Object
Transmogrify using the singleton transmogrifier registry.
Methods included from ClassMethods
event_bus, transmogrifier_registry
Instance Method Details
#autotransmogrify(from, options = {}) ⇒ Object
Automatically transmogrify one event type to another, and publish the result. By default, a transmogrifier that returns a nil object simply does not publish a result.
107 108 109 110 |
# File 'lib/octiron/world.rb', line 107 def autotransmogrify(from, = {}) verify_results = [:verify_results] || false return AutoTransmogrifyDelegator.new(from, verify_results) end |
#on_event(event_id, handler_object = nil, handler_class = ::Octiron::Events::Bus::DEFAULT_CLASS, &handler_proc) ⇒ Object
Subscribe an event handler to an event with the singleton event bus
120 121 122 123 124 125 |
# File 'lib/octiron/world.rb', line 120 def on_event(event_id, handler_object = nil, handler_class = ::Octiron::Events::Bus::DEFAULT_CLASS, &handler_proc) ::Octiron::World.event_bus.subscribe(event_id, handler_object, handler_class, &handler_proc) end |
#on_transmogrify(from) ⇒ Object
Register a transmogrifier with the singleton transmogrifier registry
99 100 101 |
# File 'lib/octiron/world.rb', line 99 def on_transmogrify(from) return TransmogrifierRegistrator.new(from) end |
#publish(event) ⇒ Object
Publish an event on the singleton event bus
129 130 131 |
# File 'lib/octiron/world.rb', line 129 def publish(event) ::Octiron::World.event_bus.publish(event) end |
#transmogrify(from) ⇒ Object
Transmogrify using the singleton transmogrifier registry
114 115 116 |
# File 'lib/octiron/world.rb', line 114 def transmogrify(from) return TransmogrifyDelegator.new(from) end |