Sha256: d9dfc5b42d7afeb4720406d00ef1039cfa745f8d4bce8c6a6d4533f2fcbc67b6

Contents?: true

Size: 581 Bytes

Versions: 1

Compression:

Stored size: 581 Bytes

Contents

module Hydra::Works
  # Allows instances of a class to aggregate (pcdm:hasMember) hydra-works collections
  module AggregatesCollections

    def collections= collections
      raise ArgumentError, "each collection must be a hydra works collection" unless collections.all? { |c| Hydra::Works.collection? c }
      raise ArgumentError, "a collection can't be an ancestor of itself" if collection_ancestor?(collections)
      self.members = self.generic_works + collections
    end

    def collections
      members.to_a.select { |m| Hydra::Works.collection? m }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hydra-works-0.0.1 lib/hydra/works/models/concerns/aggregates_collections.rb