Class: Cliqr::Config::EventBased Private
- Defined in:
- lib/cliqr/config/event_based.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.
The configuration that enabled events for another configuration
Direct Known Subclasses
Instance Attribute Summary collapse
-
#events ⇒ Hash
private
Events to listen for.
Instance Method Summary collapse
-
#event(name) ⇒ Cliqr::Config::Event
private
Get a event handler config by name.
-
#handle?(name) ⇒ Boolean
private
Check if a event can be handled in this context.
-
#initialize ⇒ EventBased
constructor
private
New instance of event based config.
-
#set_config(name, event_name, *args, &block) ⇒ Cliqr::Config::Event
private
Add a event.
Methods inherited from Base
Methods included from Validation
#errors, included, #read_attributes, #valid?, #validate, #validations
Methods included from DSL
Constructor Details
#initialize ⇒ EventBased
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.
New instance of event based config
17 18 19 |
# File 'lib/cliqr/config/event_based.rb', line 17 def initialize @events = {} end |
Instance Attribute Details
#events ⇒ Hash
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.
Events to listen for
12 13 14 |
# File 'lib/cliqr/config/event_based.rb', line 12 def events @events end |
Instance Method Details
#event(name) ⇒ Cliqr::Config::Event
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.
Get a event handler config by name
47 48 49 |
# File 'lib/cliqr/config/event_based.rb', line 47 def event(name) @events[name.to_s] end |
#handle?(name) ⇒ 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.
Check if a event can be handled in this context
40 41 42 |
# File 'lib/cliqr/config/event_based.rb', line 40 def handle?(name) @events.key?(name.to_s) end |
#set_config(name, event_name, *args, &block) ⇒ Cliqr::Config::Event
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.
Add a event
29 30 31 32 33 34 35 36 37 |
# File 'lib/cliqr/config/event_based.rb', line 29 def set_config(name, event_name, *args, &block) case name when :on # if defined, args[0] will be the custom event handler class handle_event(event_name, args[0], &block) else super end end |