lib/spira/persistence.rb in spira-0.5.0 vs lib/spira/persistence.rb in spira-0.7

- old
+ new

@@ -1,26 +1,17 @@ module Spira module Persistence extend ActiveSupport::Concern module ClassMethods - ## - # Repository name for this class - # - # @return [Symbol] - def repository_name - # should be redefined in children, if required - # see also Spira::Resource.configure :repository option - :default - end ## # The current repository for this class # # @return [RDF::Repository, nil] def repository - Spira.repository(repository_name) + Spira.repository || raise(NoRepositoryError) end ## # Simple finder method. # @@ -231,15 +222,10 @@ # Anything that can be an RDF::URI, we re-run this case statement # on it for the fragment logic above. when identifier.respond_to?(:to_uri) && !identifier.is_a?(RDF::URI) id_for(identifier.to_uri) # see comment with #to_uri above, this might be a fragment - when identifier.is_a?(Addressable::URI) - id_for(RDF::URI.intern(identifier)) - # This is a #to_s or a URI fragment with a base uri. We'll treat them the same. - # FIXME: when #/ makes it into RDF.rb proper, this can all be wrapped - # into the one case statement above. else uri = identifier.is_a?(RDF::URI) ? identifier : RDF::URI.intern(identifier.to_s) case when uri.absolute? uri @@ -375,16 +361,13 @@ ## # Reload all attributes for this instance. # This resource will block if the underlying repository # blocks the next time it accesses attributes. # - # If repository is not defined, the attributes are just not set, - # instead of raising a Spira::NoRepositoryError. - # # NB: "props" argument is ignored, it is handled in Base # def reload(props = {}) - sts = self.class.repository && self.class.repository.query(:subject => subject) + sts = self.class.repository.query(:subject => subject) self.class.properties.each do |name, options| name = name.to_s if sts objects = sts.select { |s| s.predicate == options[:predicate] } attributes[name] = retrieve_attribute(name, options, objects)