Module: OnStomp::Interfaces::EventManager::ClassMethods
- Defined in:
- lib/onstomp/interfaces/event_manager.rb
Overview
Mixin to allow includers to define custom event methods
Instance Method Summary (collapse)
-
- (Object) create_event_method(name)
Creates a convenience method for binding callbacks to the given event name.
-
- (Object) create_event_methods(name, *prefixes)
Creates convenience methods for binding callbacks to the given event name with a set of prefixes.
-
- (Array<Symbol>) event_methods
A convenient way to get a list of all of the event methods a class has defined for itself.
Instance Method Details
- (Object) create_event_method(name)
Creates a convenience method for binding callbacks to the given event name.
59 60 61 62 |
# File 'lib/onstomp/interfaces/event_manager.rb', line 59 def create_event_method name event_methods << name module_eval "def #{name}(&block); bind_event(:#{name}, block); end" end |
- (Object) create_event_methods(name, *prefixes)
Creates convenience methods for binding callbacks to the given event name with a set of prefixes.
78 79 80 81 |
# File 'lib/onstomp/interfaces/event_manager.rb', line 78 def create_event_methods name, *prefixes prefixes << :on if prefixes.empty? prefixes.each { |pre| create_event_method :#{pre}_#{name}" } end |
- (Array<Symbol>) event_methods
A convenient way to get a list of all of the event methods a class has defined for itself. Returns an array of event method names as symbols.
44 45 46 |
# File 'lib/onstomp/interfaces/event_manager.rb', line 44 def event_methods @event_methods ||= [] end |