The letter after the number indicates the type to which you want to distinguish it. In this case, integer . It can also be f for float or s for string .
I just did it myself, and the easiest way I could find was basically copying / pasting Rails code into my base module (or abstract object).
I copied the following functions verbatim from ActiveRecord::Base
assign_multiparameter_attributes(pairs)extract_callstack_for_multiparameter_attributes(pairs)type_cast_attribute_value(multiparameter_name, value)find_parameter_position(multiparameter_name)
I also have the following methods that call / use them:
def setup_parameters(params = {}) new_params = {} multi_parameter_attributes = [] params.each do |k,v| if k.to_s.include?("(") multi_parameter_attributes << [ k.to_s, v ] else new_params[k.to_s] = v end end new_params.merge(assign_multiparameter_attributes(multi_parameter_attributes)) end
If you find a better solution, let me know :-)
source share