Module: ActiveData::Model::Associations

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_data/model/associations.rb,
lib/active_data/model/associations/base.rb,
lib/active_data/model/associations/embeds_any.rb,
lib/active_data/model/associations/embeds_one.rb,
lib/active_data/model/associations/embeds_many.rb,
lib/active_data/model/associations/validations.rb,
lib/active_data/model/associations/references_any.rb,
lib/active_data/model/associations/references_one.rb,
lib/active_data/model/associations/references_many.rb,
lib/active_data/model/associations/collection/proxy.rb,
lib/active_data/model/associations/reflections/base.rb,
lib/active_data/model/associations/nested_attributes.rb,
lib/active_data/model/associations/collection/embedded.rb,
lib/active_data/model/associations/reflections/singular.rb,
lib/active_data/model/associations/reflections/embeds_any.rb,
lib/active_data/model/associations/reflections/embeds_one.rb,
lib/active_data/model/associations/reflections/embeds_many.rb,
lib/active_data/model/associations/persistence_adapters/base.rb,
lib/active_data/model/associations/reflections/references_any.rb,
lib/active_data/model/associations/reflections/references_one.rb,
lib/active_data/model/associations/reflections/references_many.rb,
lib/active_data/model/associations/persistence_adapters/active_record.rb,
lib/active_data/model/associations/persistence_adapters/active_record/referenced_proxy.rb

Defined Under Namespace

Modules: ClassMethods, Collection, NestedAttributes, PersistenceAdapters, Reflections, Validations Classes: Base, EmbedsAny, EmbedsMany, EmbedsOne, ReferencesAny, ReferencesMany, ReferencesOne

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



88
89
90
91
92
# File 'lib/active_data/model/associations.rb', line 88

def ==(other)
  super && association_names.all? do |association|
    public_send(association) == other.public_send(association)
  end
end

#apply_association_changes!Object



101
102
103
104
105
# File 'lib/active_data/model/associations.rb', line 101

def apply_association_changes!
  association_names.all? do |name|
    association(name).apply_changes!
  end
end

#association(name) ⇒ Object



95
96
97
98
99
# File 'lib/active_data/model/associations.rb', line 95

def association(name)
  reflection = self.class.reflect_on_association(name)
  return unless reflection
  (@_associations ||= {})[reflection.name] ||= reflection.build_association(self)
end