lib/active_fedora/base.rb in active-fedora-5.5.1 vs lib/active_fedora/base.rb in active-fedora-5.5.2
- old
+ new
@@ -66,10 +66,11 @@
# Also, if +attrs+ does not contain +:pid+ but does contain +:namespace+ it will pass the
# +:namespace+ value to Fedora::Repository.nextid to generate the next pid available within
# the given namespace.
def initialize(attrs = nil)
attrs = {} if attrs.nil?
+ @association_cache = {}
attributes = attrs.dup
@inner_object = UnsavedDigitalObject.new(self.class, attributes.delete(:namespace), attributes.delete(:pid))
self.relationships_loaded = true
load_datastreams
@@ -78,10 +79,11 @@
run_callbacks :initialize
end
# Reloads the object from Fedora.
def reload
+ clear_association_cache
init_with(self.class.find(self.pid).inner_object)
end
# Initialize an empty model object and set the +inner_obj+
# example:
@@ -92,9 +94,10 @@
#
# post = Post.allocate
# post.init_with(DigitalObject.find(pid))
# post.properties.title # => 'hello world'
def init_with(inner_obj)
+ @association_cache = {}
@inner_object = inner_obj
unless @inner_object.is_a? SolrDigitalObject
@inner_object.original_class = self.class
## Replace existing unchanged datastreams with the definitions found in this class if they have a different type.
## Any datastream that is deleted here will cause a reload from fedora, so avoid it whenever possible