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.



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/ar_doc_store/attributes/embeds_many.rb', line 96

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.



95
96
97
# File 'lib/ar_doc_store/attributes/embeds_many.rb', line 95

def class_name
  @class_name
end

#modelsObject

Returns the value of attribute models.



95
96
97
# File 'lib/ar_doc_store/attributes/embeds_many.rb', line 95

def models
  @models
end

#parentObject (readonly)

Returns the value of attribute parent.



95
96
97
# File 'lib/ar_doc_store/attributes/embeds_many.rb', line 95

def parent
  @parent
end