class ATC::ValueParser::HasMany
Public Instance Methods
parse()
click to toggle source
should return a pattern like⦠{
loads_attributes: { "0" => { pays_fuel_surcharge: true, pickup_datetime: #datetime_object } }
}
# File lib/air_traffic_control/value_parser/has_many.rb, line 15 def parse return input_value unless input_value.present? return parse_hash if input_value.is_a?(Hash) return parse_array if input_value.is_a?(Array) end
parse_array()
click to toggle source
# File lib/air_traffic_control/value_parser/has_many.rb, line 30 def parse_array hash = {} input_value.each_with_index do |obj_hash, index| object_hash = form.new(obj_hash).params hash[index] = object_hash end hash end
parse_hash()
click to toggle source
# File lib/air_traffic_control/value_parser/has_many.rb, line 21 def parse_hash hash = {} input_value.each do |index, obj_hash| object_hash = form.new(obj_hash).params hash[index] = object_hash end hash end