Class: Para::AttributeField::NestedOneField

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

Instance Attribute Summary

Attributes inherited from Base

#field_method, #field_type, #model, #name, #options, #type

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

Methods inherited from BelongsToField

#field_name, #relation_options, #value_for

Methods inherited from RelationField

#foreign_key, #polymorphic_through_reflection?, #reflection, #through_reflection, #through_relation, #through_relation_source_foreign_key

Methods included from Helpers::ResourceName

#resource_name

Methods inherited from Base

#attribute_column_path, #determine_name_and_field_method!, #excerptable_value?, #field_name, field_option, #field_options, field_types, #initialize, register, #searchable?, #type?, #value_for

Constructor Details

This class inherits a constructor from Para::AttributeField::Base

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