Class: ArDocStore::Attributes::AssignEmbedsManyAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/ar_doc_store/attributes/embeds_many.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, class_name, assn_name, models, values) ⇒ AssignEmbedsManyAttributes

Returns a new instance of AssignEmbedsManyAttributes.



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/ar_doc_store/attributes/embeds_many.rb', line 93

def initialize(parent, class_name, assn_name, models, values)
  @parent, @class_name, @assn_name, @models, @values = parent, class_name, assn_name, models, values
  @models ||= ArDocStore::EmbeddedCollection.new
  values.each { |value|
    value = value.symbolize_keys
    if value.key?(:id)
      process_existing_model(value)
    else
      next if value.values.all? { |value| value.nil? || value == '' }
      add(value)
    end
  }
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



92
93
94
# File 'lib/ar_doc_store/attributes/embeds_many.rb', line 92

def class_name
  @class_name
end

#modelsObject

Returns the value of attribute models.



92
93
94
# File 'lib/ar_doc_store/attributes/embeds_many.rb', line 92

def models
  @models
end

#parentObject (readonly)

Returns the value of attribute parent.



92
93
94
# File 'lib/ar_doc_store/attributes/embeds_many.rb', line 92

def parent
  @parent
end