class Dor::CollectionService
Adds and removes collections to and from objects Collections are added as Collections and Sets.
Attributes
obj[R]
Public Class Methods
new(obj)
click to toggle source
# File lib/dor/services/collection_service.rb, line 7 def initialize(obj) @obj = obj end
Public Instance Methods
add(collection_or_druid)
click to toggle source
# File lib/dor/services/collection_service.rb, line 11 def add(collection_or_druid) collection = dereference(collection_or_druid) obj.collections << collection obj.sets << collection end
remove(collection_or_druid)
click to toggle source
# File lib/dor/services/collection_service.rb, line 17 def remove(collection_or_druid) collection = dereference(collection_or_druid) obj.collections.delete(collection) obj.sets.delete(collection) end
Private Instance Methods
dereference(collection_or_druid)
click to toggle source
# File lib/dor/services/collection_service.rb, line 27 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