Module: SKUI::Events::EventDefinitions
- Defined in:
- src/SKUI/events.rb
Overview
The methods defined here becomes ‘static’ class methods.
Instance Method Summary collapse
-
#set(event, ...) ⇒ Nil
Defines an event for the control.
-
#events ⇒ Array<Symbol>
Returns an array of availible events.
- #has_event?(event) ⇒ Array<Symbol>
-
#inherited(subclass) ⇒ Object
When a new class inherits the class that include Events we want to make sure that the event definitions of the superclass is cascaded into the subclass.
Instance Method Details
#set(event, ...) ⇒ Nil
Defines an event for the control. If an event is not defined it cannot be called.
119 120 121 122 123 124 125 126 127 |
# File 'src/SKUI/events.rb', line 119 def define_event( *args ) for event in args unless event.is_a?( Symbol ) raise( ArgumentError, 'Expected a Symbol' ) end @control_events[event] = event end nil end |
#events ⇒ Array<Symbol>
Returns an array of availible events.
133 134 135 |
# File 'src/SKUI/events.rb', line 133 def events @control_events.keys end |
#has_event?(event) ⇒ Array<Symbol>
139 140 141 |
# File 'src/SKUI/events.rb', line 139 def has_event?( event ) @control_events.key?( event ) end |
#inherited(subclass) ⇒ Object
When a new class inherits the class that include Events we want to make sure that the event definitions of the superclass is cascaded into the subclass. This is done here by copying the event defintions.
106 107 108 109 |
# File 'src/SKUI/events.rb', line 106 def inherited( subclass ) parent_events = instance_variable_get( :@control_events ).dup subclass.instance_variable_set( :@control_events, parent_events ) end |