Class: Para::AttributeField::NestedOneField

Inherits:
AttributeField::BelongsToField
  • Object
show all
Includes:
NestedField, Helpers::AttributesMappings
Defined in:
lib/para/attribute_field/nested_one.rb

Instance Method Summary collapse

Methods included from NestedField

#nested_attributes_key, #nested_model_mappings, #temporarily_extend_new_resource

Methods included from Helpers::AttributesMappings

#attributes_mappings_for

Instance Method Details

#parse_input(params, resource) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/para/attribute_field/nested_one.rb', line 9

def parse_input(params, resource)
  if (nested_attributes = params[nested_attributes_key])
    nested_resource = fetch_or_build_nested_resource_for(resource, nested_attributes)
    mappings = nested_model_mappings(nested_attributes, nested_resource)

    mappings.fields.each do |field|
      field.parse_input(nested_attributes, nested_resource)
    end

    params[nested_attributes_key] = nested_attributes
  else
    super
  end
end