module Octiron::World
World
module, putting together the event bus and transmogrifier registry with easy access functions.
Public Instance Methods
autotransmogrify(from, options = {})
click to toggle source
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.
# File lib/octiron/world.rb, line 107 def autotransmogrify(from, options = {}) verify_results = options[: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)
click to toggle source
Subscribe an event handler to an event with the singleton event bus
# 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)
click to toggle source
Register a transmogrifier with the singleton transmogrifier registry
# File lib/octiron/world.rb, line 99 def on_transmogrify(from) return TransmogrifierRegistrator.new(from) end
publish(event)
click to toggle source
Publish an event on the singleton event bus
# File lib/octiron/world.rb, line 129 def publish(event) ::Octiron::World.event_bus.publish(event) end
transmogrify(from)
click to toggle source
Transmogrify using the singleton transmogrifier registry
# File lib/octiron/world.rb, line 114 def transmogrify(from) return TransmogrifyDelegator.new(from) end