Sha256: 1924bd393c568e3451b2d21ceeaf7af9ca17897465446955e5ae0f0142bb4c42

Contents?: true

Size: 943 Bytes

Versions: 20

Compression:

Stored size: 943 Bytes

Contents

# This is the parent class of DirectlyContainsAssociation and IndirectlyContainsAssociation
module ActiveFedora
  module Associations
    class ContainsAssociation < CollectionAssociation #:nodoc:
      def reader
        @records ||= ContainerProxy.new(self)
      end

      def include?(other)
        if loaded?
          target.include?(other)
        elsif container_predicate = options[:has_member_relation]
          owner.resource.query(predicate: container_predicate, object: ::RDF::URI(other.uri)).present?
        else # is_member_of_relation
          # This will force a load, so it's slowest and the least preferable option
          target.include?(other)
        end
      end

      protected

        def count_records
          load_target.size
        end

        def uri
          raise "Can't get uri. Owner isn't saved" if @owner.new_record?
          "#{@owner.uri}/#{@reflection.name}"
        end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
active-fedora-9.7.3 lib/active_fedora/associations/contains_association.rb
active-fedora-9.7.2 lib/active_fedora/associations/contains_association.rb
active-fedora-9.12.0 lib/active_fedora/associations/contains_association.rb
active-fedora-9.11.0 lib/active_fedora/associations/contains_association.rb
active-fedora-9.10.4 lib/active_fedora/associations/contains_association.rb
active-fedora-9.10.3 lib/active_fedora/associations/contains_association.rb
active-fedora-9.10.2 lib/active_fedora/associations/contains_association.rb
active-fedora-9.10.1 lib/active_fedora/associations/contains_association.rb
active-fedora-9.10.0 lib/active_fedora/associations/contains_association.rb
active-fedora-9.10.0.pre2 lib/active_fedora/associations/contains_association.rb
active-fedora-9.10.0.pre1 lib/active_fedora/associations/contains_association.rb
active-fedora-9.9.1 lib/active_fedora/associations/contains_association.rb
active-fedora-9.9.0 lib/active_fedora/associations/contains_association.rb
active-fedora-9.8.2 lib/active_fedora/associations/contains_association.rb
active-fedora-9.8.1 lib/active_fedora/associations/contains_association.rb
active-fedora-9.8.0 lib/active_fedora/associations/contains_association.rb
active-fedora-9.7.1 lib/active_fedora/associations/contains_association.rb
active-fedora-9.7.0 lib/active_fedora/associations/contains_association.rb
active-fedora-9.6.2 lib/active_fedora/associations/contains_association.rb
active-fedora-9.6.1 lib/active_fedora/associations/contains_association.rb