Module: ActiveFedora::Associations

Extended by:
ActiveSupport::Autoload, ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_fedora/associations/has_and_belongs_to_many_association.rb,
lib/active_fedora/associations.rb,
lib/active_fedora/associations/rdf.rb,
lib/active_fedora/associations/association.rb,
lib/active_fedora/associations/delete_proxy.rb,
lib/active_fedora/associations/id_composite.rb,
lib/active_fedora/associations/singular_rdf.rb,
lib/active_fedora/associations/null_validator.rb,
lib/active_fedora/associations/container_proxy.rb,
lib/active_fedora/associations/collection_proxy.rb,
lib/active_fedora/associations/contained_finder.rb,
lib/active_fedora/associations/record_composite.rb,
lib/active_fedora/associations/association_scope.rb,
lib/active_fedora/associations/filter_association.rb,
lib/active_fedora/associations/orders_association.rb,
lib/active_fedora/associations/contains_association.rb,
lib/active_fedora/associations/has_many_association.rb,
lib/active_fedora/associations/singular_association.rb,
lib/active_fedora/associations/belongs_to_association.rb,
lib/active_fedora/associations/collection_association.rb,
lib/active_fedora/associations/basic_contains_association.rb,
lib/active_fedora/associations/has_subresource_association.rb,
lib/active_fedora/associations/directly_contains_association.rb,
lib/active_fedora/associations/indirectly_contains_association.rb,
lib/active_fedora/associations/directly_contains_one_association.rb

Overview

Active Fedora Has And Belongs To Many Association

Defined Under Namespace

Modules: Builder, ClassMethods Classes: Association, AssociationScope, BasicContainsAssociation, BelongsToAssociation, CollectionAssociation, CollectionProxy, ContainedFinder, ContainerProxy, ContainsAssociation, DeleteProxy, DirectlyContainsAssociation, DirectlyContainsOneAssociation, FilterAssociation, HasAndBelongsToManyAssociation, HasManyAssociation, HasSubresourceAssociation, IDComposite, IndirectlyContainsAssociation, NullValidator, OrdersAssociation, RDF, RecordComposite, SingularAssociation, SingularRDF

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#association_cacheObject (readonly)

:nodoc:



73
74
75
# File 'lib/active_fedora/associations.rb', line 73

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



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/active_fedora/associations.rb', line 76

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) if reflection
    association_instance_set(name, association) if association
  end

  association
end

#clear_association_cacheObject

Clears out the association cache.



68
69
70
# File 'lib/active_fedora/associations.rb', line 68

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

#deleteObject



88
89
90
91
92
93
# File 'lib/active_fedora/associations.rb', line 88

def delete(*)
  reflections.each_pair do |name, reflection|
    association(name.to_sym).delete_all if reflection.macro == :has_many
  end
  super
end