Module: Marvin::Dispatchable
- Included in:
- AbstractClient
- Defined in:
- lib/marvin/dispatchable.rb
Overview
Marvin::Dispatchable
A Generic mixin which lets you define an object Which accepts handlers which can have arbitrary events dispatched.
Usage
class X
include Marvin::Dispatchable
self.handlers << SomeHandler.new
end
X.new.dispatch(:name, {:args => "Values"})
Will first check if SomeHandler#handle_name exists, calling handle_name(=> “Values”) if it does, otherwise calling SomeHandler#handle(:name, => “Values”)
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
Class Method Details
.included(parent) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/marvin/dispatchable.rb', line 19 def self.included(parent) parent.class_eval do include InstanceMethods extend ClassMethods end end |