Class: SugarCube::ActionSheetDelegate

Inherits:
Object
  • Object
show all
Defined in:
lib/sugarcube/uiactionsheet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#button_index_mapObject

Returns the value of attribute button_index_map.



92
93
94
# File 'lib/sugarcube/uiactionsheet.rb', line 92

def button_index_map
  @button_index_map
end

#on_cancelObject

Returns the value of attribute on_cancel.



93
94
95
# File 'lib/sugarcube/uiactionsheet.rb', line 93

def on_cancel
  @on_cancel
end

#on_destructiveObject

Returns the value of attribute on_destructive.



94
95
96
# File 'lib/sugarcube/uiactionsheet.rb', line 94

def on_destructive
  @on_destructive
end

#on_successObject

Returns the value of attribute on_success.



95
96
97
# File 'lib/sugarcube/uiactionsheet.rb', line 95

def on_success
  @on_success
end

Instance Method Details

#actionSheet(alert, didDismissWithButtonIndex: index) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/sugarcube/uiactionsheet.rb', line 97

def actionSheet(alert, didDismissWithButtonIndex:index)
  if index == alert.destructiveButtonIndex && on_destructive
    on_destructive.call
  elsif index == alert.cancelButtonIndex && on_cancel
    on_cancel.call
  elsif on_success
    if on_success.arity == 0
      on_success.call
    else
      button = button_index_map[index]
      on_success.call(button)
    end
  end

  self.send(:autorelease)
end