lib/ProMotion/table/table_builder.rb in ProMotion-2.4.2 vs lib/ProMotion/table/table_builder.rb in ProMotion-2.5.0.beta1
- old
+ new
@@ -1,12 +1,14 @@
module ProMotion
module TableBuilder
def trigger_action(action, arguments, index_path)
- return mp("Action not implemented: #{action.to_s}", force_color: :green) unless self.respond_to?(action)
- case self.method(action).arity
- when 0 then self.send(action) # Just call the method
- when 2 then self.send(action, arguments, index_path) # Send arguments and index path
- else self.send(action, arguments) # Send arguments
+ 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
def create_table_cell(data_cell)
new_cell = nil