Module: SKUI::Events::EventDefinitions

Defined in:
src/SKUI/events.rb

Overview

The methods defined here becomes ‘static’ class methods.

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

#set(event, ...) ⇒ Nil

Defines an event for the control. If an event is not defined it cannot be called.

Parameters:

  • event (Symbol)

Returns:

  • (Nil)

Since:

  • 1.0.0



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

#eventsArray<Symbol>

Returns an array of availible events.

Returns:

  • (Array<Symbol>)

Since:

  • 1.0.0



133
134
135
# File 'src/SKUI/events.rb', line 133

def events
  @control_events.keys
end

#has_event?(event) ⇒ Array<Symbol>

Returns:

  • (Array<Symbol>)

Since:

  • 1.0.0



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.

Parameters:

  • subclass (Class)

Since:

  • 1.0.0



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