class Goaltender::ValueParser::HasMany

Attributes

form_class[R]
variable_name[R]

Public Instance Methods

after_init(args) click to toggle source
# File lib/goaltender/value_parser/has_many.rb, line 7
def after_init(args)
  @form_class = args[:form_class]
  @variable_name = args[:variable_name]
end
parse() click to toggle source

should return a pattern like… {

loads_attributes: {
  "0" => {
    pays_fuel_surcharge: true,
    pickup_datetime: #datetime_object
  }
}

}

# File lib/goaltender/value_parser/has_many.rb, line 21
def parse
  return input_value unless input_value.present?
  hash = {}
  input_value.each do |index, obj_hash|
    object_hash = form_class.constantize.new(obj_hash).to_h
    hash[index] = object_hash
  end
  hash
end