class Microstation::EventHandler
Public Class Methods
new()
click to toggle source
# File lib/microstation/event_handler.rb, line 4 def initialize @handlers = {} end
Public Instance Methods
add_handler(event, &block)
click to toggle source
# File lib/microstation/event_handler.rb, line 8 def add_handler(event, &block) if block_given? @handlers[event] = block end end
get_handler(event)
click to toggle source
# File lib/microstation/event_handler.rb, line 14 def get_handler(event) @handlers[event] end
method_missing(event, *args)
click to toggle source
Calls superclass method
# File lib/microstation/event_handler.rb, line 18 def method_missing(event, *args) if @handlers[event.to_s] @handlers[event.to_s].call(*args) else puts "Unhandled event: #{event} args: #{args}" super end end