Module: Brainguy::Observer
- Defined in:
- lib/brainguy/observer.rb
Overview
A mixin for formal "listener" classes. Events received by the including
class will be dispatched to #on_<EVENT_NAME>
methods, if they exist. If
no event-specific handler method is found, it will be sent to
#event_handler_missing.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#call(event) ⇒ Object
Dispatch events to handler methods.
-
#event_handler_missing(event) ⇒ Object
Empty placeholder in case the client class doesn't supply a custom
#event_handler_missing
.
Class Method Details
.included(klass) ⇒ Object
52 53 54 55 |
# File 'lib/brainguy/observer.rb', line 52 def self.included(klass) klass.extend(ClassMethods) klass.regenerate_dispatch_method end |
Instance Method Details
#call(event) ⇒ Object
Dispatch events to handler methods.
This method is automatically [re]generated by
Brainguy::Observer::ClassMethods#regenerate_dispatch_method every time a new
#on_*
method is defined.
|
# File 'lib/brainguy/observer.rb', line 64
|
#event_handler_missing(event) ⇒ Object
Empty placeholder in case the client class doesn't supply a custom
#event_handler_missing
60 61 62 |
# File 'lib/brainguy/observer.rb', line 60 def event_handler_missing(event) # just a placeholder end |