Module: DatastaxRails::Associations

Extended by:
ActiveSupport::Autoload, ActiveSupport::Concern
Included in:
Base
Defined in:
lib/datastax_rails/associations.rb,
lib/datastax_rails/associations/association.rb,
lib/datastax_rails/associations/collection_proxy.rb,
lib/datastax_rails/associations/association_scope.rb,
lib/datastax_rails/associations/has_one_association.rb,
lib/datastax_rails/associations/has_many_association.rb,
lib/datastax_rails/associations/singular_association.rb,
lib/datastax_rails/associations/belongs_to_association.rb,
lib/datastax_rails/associations/collection_association.rb,
lib/datastax_rails/associations/has_and_belongs_to_many_association.rb

Overview

DatastaxRails Has And Belongs To Many Association

Defined Under Namespace

Modules: Builder, ClassMethods Classes: Association, AssociationScope, BelongsToAssociation, CollectionAssociation, CollectionProxy, HasAndBelongsToManyAssociation, HasManyAssociation, HasOneAssociation, SingularAssociation

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#association_cacheObject (readonly)

:nodoc:



36
37
38
# File 'lib/datastax_rails/associations.rb', line 36

def association_cache
  @association_cache
end

Instance Method Details

#association(name) ⇒ Object

Returns the association instance for the given name, instantiating it if it doesn't already exist



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/datastax_rails/associations.rb', line 39

def association(name) #:nodoc:
  association = association_instance_get(name)

  if association.nil?
    reflection = self.class.reflect_on_association(name)
    association = reflection.association_class.new(self, reflection)
    association_instance_set(name, association)
  end

  association
end

#clear_association_cacheObject

Clears out the association cache.



31
32
33
# File 'lib/datastax_rails/associations.rb', line 31

def clear_association_cache #:nodoc:
  @association_cache.clear if persisted?
end