Class: EventHandlerWrapper

Inherits:
Object
  • Object
show all
Includes:
EventHandler
Defined in:
lib/fxmlloader/elts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctrl, funcName) ⇒ EventHandlerWrapper

Returns a new instance of EventHandlerWrapper.



514
515
516
517
# File 'lib/fxmlloader/elts.rb', line 514

def initialize(ctrl, funcName)
  @ctrl = ctrl
  @funcName = funcName
end

Instance Attribute Details

#funcNameObject (readonly)

Returns the value of attribute funcName.



513
514
515
# File 'lib/fxmlloader/elts.rb', line 513

def funcName
  @funcName
end

Instance Method Details

#handle(eventArgs) ⇒ Object



518
519
520
521
522
523
524
525
526
527
528
# File 'lib/fxmlloader/elts.rb', line 518

def handle(eventArgs)
  if @ctrl.respond_to? @funcName
    if @ctrl.method(@funcName).arity == 0
      @ctrl.send(@funcName)
    else
      @ctrl.send(@funcName, eventArgs)
    end
  else
    puts "Warning: method #{@funcName} was not found on controller #{@ctrl}"
  end
end