Module: EmbeddedAssociation

Includes:
AbstractModel
Included in:
ManyEmbeddedAssociation, OneEmbeddedAssociation
Defined in:
lib/yodel/models/core/associations/embedded/embedded_association.rb

Instance Method Summary collapse

Methods included from AbstractModel

#embed_many, #embed_one, #field, #many, #modify_field, #one, #remove_field

Instance Method Details

#default_input_typeObject



21
22
23
# File 'lib/yodel/models/core/associations/embedded/embedded_association.rb', line 21

def default_input_type
  :embedded
end

#fieldsObject



8
9
10
# File 'lib/yodel/models/core/associations/embedded/embedded_association.rb', line 8

def fields
  @fields ||= fields_field.typecast(@options['fields'], nil)
end

#fields_fieldObject



4
5
6
# File 'lib/yodel/models/core/associations/embedded/embedded_association.rb', line 4

def fields_field
  @fields_field ||= FieldsField.new(name)
end

#optionsObject



12
13
14
# File 'lib/yodel/models/core/associations/embedded/embedded_association.rb', line 12

def options
  @options.merge({'fields' => fields_field.untypecast(fields, nil)})
end

#validate(record, errors) ⇒ Object



16
17
18
19
# File 'lib/yodel/models/core/associations/embedded/embedded_association.rb', line 16

def validate(record, errors)
  EmbeddedRecordsValidation.validate(self, record.get(name), record, errors)
  super(record, errors)
end