Class: Para::AttributeField::NestedOneField

Inherits:
BelongsToField show all
Defined in:
lib/para/attribute_field/nested_one.rb

Instance Attribute Summary

Attributes inherited from Base

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

Instance Method Summary collapse

Methods inherited from BelongsToField

#field_name, #relation_options, #value_for

Methods inherited from Base

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

Constructor Details

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

Instance Method Details

#nested_attributes_keyObject



22
23
24
# File 'lib/para/attribute_field/nested_one.rb', line 22

def nested_attributes_key
  @nested_attributes_key ||= :"#{ name }_attributes"
end

#nested_model_mappingsObject



18
19
20
# File 'lib/para/attribute_field/nested_one.rb', line 18

def nested_model_mappings
  @nested_model_mappings ||= AttributeFieldMappings.new(reflection.klass)
end

#parse_input(params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/para/attribute_field/nested_one.rb', line 6

def parse_input(params)
  if (nested_attributes = params[nested_attributes_key])
    nested_model_mappings.fields.each do |field|
      field.parse_input(nested_attributes)
    end

    params[nested_attributes_key] = nested_attributes
  else
    super(params)
  end
end