Sha256: a76598c4983f16f8d8346b0a5d8680d2e83ea0b9c6903f85ce5f3daaf01fe29e
Contents?: true
Size: 811 Bytes
Versions: 12
Compression:
Stored size: 811 Bytes
Contents
# frozen_string_literal: true module Dor # Adds and removes collections to and from objects # Collections are added as Collections and Sets. class CollectionService def initialize(obj) @obj = obj end def add(collection_or_druid) collection = dereference(collection_or_druid) obj.collections << collection obj.sets << collection end def remove(collection_or_druid) collection = dereference(collection_or_druid) obj.collections.delete(collection) obj.sets.delete(collection) end private attr_reader :obj def dereference(collection_or_druid) case collection_or_druid when String Dor::Collection.find(collection_or_druid) when Dor::Collection collection_or_druid end end end end
Version data entries
12 entries across 12 versions & 1 rubygems