Class: SugarCube::UIControlCallbackHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/ios/sugarcube-events/uicontrol.rb

Instance Method Summary collapse

Constructor Details

#initialize(callback) ⇒ UIControlCallbackHelper

Returns a new instance of UIControlCallbackHelper.



84
85
86
# File 'lib/ios/sugarcube-events/uicontrol.rb', line 84

def initialize(callback)
  @callback = callback.respond_to?('weak!') ? callback.weak! : callback
end

Instance Method Details

#call(sender, event: event) ⇒ Object



88
89
90
91
92
93
94
95
96
97
# File 'lib/ios/sugarcube-events/uicontrol.rb', line 88

def call(sender, event:event)
  case @callback.arity
  when 0
    @callback.call
  when 1
    @callback.call(sender)
  else
    @callback.call(sender, event)
  end
end