Module: Granite::Form::Model::Associations

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/granite/form/model/associations.rb,
lib/granite/form/model/associations/base.rb,
lib/granite/form/model/associations/embeds_any.rb,
lib/granite/form/model/associations/embeds_one.rb,
lib/granite/form/model/associations/embeds_many.rb,
lib/granite/form/model/associations/validations.rb,
lib/granite/form/model/associations/references_any.rb,
lib/granite/form/model/associations/references_one.rb,
lib/granite/form/model/associations/references_many.rb,
lib/granite/form/model/associations/collection/proxy.rb,
lib/granite/form/model/associations/reflections/base.rb,
lib/granite/form/model/associations/nested_attributes.rb,
lib/granite/form/model/associations/collection/embedded.rb,
lib/granite/form/model/associations/reflections/singular.rb,
lib/granite/form/model/associations/reflections/embeds_any.rb,
lib/granite/form/model/associations/reflections/embeds_one.rb,
lib/granite/form/model/associations/reflections/embeds_many.rb,
lib/granite/form/model/associations/persistence_adapters/base.rb,
lib/granite/form/model/associations/reflections/references_any.rb,
lib/granite/form/model/associations/reflections/references_one.rb,
lib/granite/form/model/associations/reflections/references_many.rb,
lib/granite/form/model/associations/persistence_adapters/active_record.rb,
lib/granite/form/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?



90
91
92
93
94
# File 'lib/granite/form/model/associations.rb', line 90

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

#association(name) ⇒ Object



98
99
100
101
102
103
# File 'lib/granite/form/model/associations.rb', line 98

def association(name)
  reflection = self.class.reflect_on_association(name)
  return unless reflection

  (@_associations ||= {})[reflection.name] ||= reflection.build_association(self)
end