Class: OneEmbeddedAssociation
Constant Summary
Constants inherited
from Field
Field::TYPES
Instance Attribute Summary
Attributes inherited from Field
#name
Instance Method Summary
collapse
#before_destroy, #typecast
#default_input_type, #fields, #fields_field, #validate
#embed_many, #embed_one, #field, #fields, #many, #modify_field, #one, #remove_field
Methods inherited from Association
#from_json, #json_action
Methods inherited from Field
#default_input_type, #display?, field_from_type, #from_json, from_options, #include_in_search_keywords?, #index?, #inherited?, #initialize, #method_missing, #numeric?, #required?, #searchable?, #strip_nil?, #to_json, #to_str, #typecast, #unique?, #validate
Constructor Details
This class inherits a constructor from Field
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Field
Instance Method Details
#default ⇒ Object
13
14
15
|
# File 'lib/yodel/models/core/associations/embedded/one_embedded_association.rb', line 13
def default
@options['default'] || EmbeddedRecord.new(self, nil).default_values
end
|
#destroy(embedded_record, parent_record) ⇒ Object
25
26
27
28
|
# File 'lib/yodel/models/core/associations/embedded/one_embedded_association.rb', line 25
def destroy(embedded_record, parent_record)
embedded_record.initialize(self, parent_record)
parent_record.changed!(name)
end
|
#options ⇒ Object
17
18
19
|
# File 'lib/yodel/models/core/associations/embedded/one_embedded_association.rb', line 17
def options
super.merge({'type' => 'one_embedded'})
end
|
#save(embedded_record, parent_record) ⇒ Object
21
22
23
|
# File 'lib/yodel/models/core/associations/embedded/one_embedded_association.rb', line 21
def save(embedded_record, parent_record)
end
|
#search_terms_set(record) ⇒ Object
9
10
11
|
# File 'lib/yodel/models/core/associations/embedded/one_embedded_association.rb', line 9
def search_terms_set(record)
record.get(name).search_terms
end
|
#untypecast(value, record) ⇒ Object
30
31
32
33
34
|
# File 'lib/yodel/models/core/associations/embedded/one_embedded_association.rb', line 30
def untypecast(value, record)
return {} unless value.is_a?(EmbeddedRecord)
value.save
value.values
end
|