Class: Cliqr::Events::Invoker Private
- Inherits:
-
Object
- Object
- Cliqr::Events::Invoker
- Defined in:
- lib/cliqr/events/invoker.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Invokes a event and associated event-chain by propagating the event
Instance Method Summary collapse
-
#initialize(config, context) ⇒ Invoker
constructor
private
Create a new event invoker instance.
-
#invoke(event_name, parent_event, *args) ⇒ Boolean
private
Invoke a event in the context of the configuration set in this invoker.
Constructor Details
#initialize(config, context) ⇒ Invoker
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new event invoker instance
15 16 17 18 |
# File 'lib/cliqr/events/invoker.rb', line 15 def initialize(config, context) @config = config @context = context end |
Instance Method Details
#invoke(event_name, parent_event, *args) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Invoke a event in the context of the configuration set in this invoker
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cliqr/events/invoker.rb', line 23 def invoke(event_name, parent_event, *args) handled = false current_config = @config event = build_event(event_name, parent_event) loop do if current_config.handle?(event_name) handle(event, current_config.event(event_name), *args) handled = true break unless event.propagate? end break if current_config.root? current_config = current_config.parent end handled end |