Module: Easyop::Plugins::EventHandlers::ClassMethods
- Defined in:
- lib/easyop/plugins/event_handlers.rb
Instance Method Summary collapse
- #_event_handler_registrations ⇒ Object
-
#on(pattern, async: false, **options) ⇒ Object
Subscribe this operation to events matching
pattern.
Instance Method Details
#_event_handler_registrations ⇒ Object
70 71 72 |
# File 'lib/easyop/plugins/event_handlers.rb', line 70 def _event_handler_registrations @_event_handler_registrations ||= [] end |
#on(pattern, async: false, **options) ⇒ Object
Subscribe this operation to events matching pattern.
Registration happens at class-load time and is bound to the bus that is active when the class is evaluated. Configure the bus before loading handler classes (e.g. in a Rails initializer that runs before autoloading).
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/easyop/plugins/event_handlers.rb', line 58 def on(pattern, async: false, **) _event_handler_registrations << { pattern: pattern, async: async, options: } Easyop::Events::Registry.register_handler( pattern: pattern, handler_class: self, async: async, ** ) end |