Module: ProMotion::TableBuilder
- Included in:
- GroupedTableScreen, Table, TableScreen
- Defined in:
- lib/ProMotion/table/table_builder.rb
Instance Method Summary collapse
- #create_table_cell(data_cell) ⇒ Object
- #on_cell_created(new_cell, data_cell) ⇒ Object
- #on_cell_reused(cell, data) ⇒ Object
- #trigger_action(action, arguments, index_path) ⇒ Object
Instance Method Details
#create_table_cell(data_cell) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ProMotion/table/table_builder.rb', line 14 def create_table_cell(data_cell) new_cell = nil table_cell = table_view.dequeueReusableCellWithIdentifier(data_cell[:cell_identifier]) || begin new_cell = data_cell[:cell_class].alloc.initWithStyle(data_cell[:cell_style], reuseIdentifier:data_cell[:cell_identifier]) new_cell.extend(PM::TableViewCellModule) unless new_cell.is_a?(PM::TableViewCellModule) new_cell.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin new_cell.clipsToBounds = true # fix for changed default in 7.1 on_cell_created new_cell, data_cell new_cell end table_cell.setup(data_cell, self) if table_cell.respond_to?(:setup) on_cell_reused(table_cell, data_cell) if !new_cell table_cell end |
#on_cell_created(new_cell, data_cell) ⇒ Object
29 30 31 |
# File 'lib/ProMotion/table/table_builder.rb', line 29 def on_cell_created(new_cell, data_cell) new_cell.send(:on_load) if new_cell.respond_to?(:on_load) end |
#on_cell_reused(cell, data) ⇒ Object
33 34 35 |
# File 'lib/ProMotion/table/table_builder.rb', line 33 def on_cell_reused(cell, data) cell.send(:on_reuse) if cell.respond_to?(:on_reuse) end |
#trigger_action(action, arguments, index_path) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/ProMotion/table/table_builder.rb', line 3 def trigger_action(action, arguments, index_path) action = (action.is_a?(Proc) ? action : method(action)) case arity = action.arity when 0 then action.call # Just call the proc or the method when 2 then action.call(arguments, index_path) # Send arguments and index path else mp("Action should not have optional parameters: #{action.to_s} in #{self.inspect}", force_color: :yellow) if arity < 0 action.call(arguments) # Send arguments end end |