Sha256: 9eab2124a7a4b1b7bd7d5b63595082a3e38d055f84b0fa9a985a6390148a9dc7

Contents?: true

Size: 960 Bytes

Versions: 10

Compression:

Stored size: 960 Bytes

Contents

module ActiveFedora::Associations
  ##
  # A Composite for records - currently only supports delete interface.
  # The goal is to push commands down to the containing records.
  class RecordComposite
    attr_reader :records
    include Enumerable
    def initialize(records:)
      @records = records
    end

    def each
      records.each do |record|
        yield record
      end
    end

    def delete
      self.each(&:delete)
    end
    ##
    # A Repository which returns a composite from #find instead of a single
    # record. Delegates find to a base repository.
    class Repository
      attr_reader :base_repository
      delegate :translate_uri_to_id, to: :base_repository
      def initialize(base_repository:)
        @base_repository = base_repository
      end

      def find(ids)
        records = ids.map do |id|
          base_repository.find(id)
        end
        RecordComposite.new(records: records)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
active-fedora-9.5.0 lib/active_fedora/associations/record_composite.rb
active-fedora-9.4.3 lib/active_fedora/associations/record_composite.rb
active-fedora-9.4.2 lib/active_fedora/associations/record_composite.rb
active-fedora-9.4.1 lib/active_fedora/associations/record_composite.rb
active-fedora-9.4.0 lib/active_fedora/associations/record_composite.rb
active-fedora-9.3.0 lib/active_fedora/associations/record_composite.rb
active-fedora-9.2.1 lib/active_fedora/associations/record_composite.rb
active-fedora-9.2.0 lib/active_fedora/associations/record_composite.rb
active-fedora-9.2.0.rc2 lib/active_fedora/associations/record_composite.rb
active-fedora-9.2.0.rc1 lib/active_fedora/associations/record_composite.rb