class Dor::Abstract

Public Class Methods

assign_pid(_obj) click to toggle source

Overrides the method in ActiveFedora to mint a pid using SURI rather than the default Fedora sequence

Calls superclass method
# File lib/dor/models/abstract.rb, line 45
def self.assign_pid(_obj)
  return Dor::SuriService.mint_id if Dor::Config.suri.mint_ids

  super
end
has_object_type(str) click to toggle source
# File lib/dor/models/abstract.rb, line 38
def self.has_object_type(str)
  self.object_type = str
  Dor.registered_classes[str] = self
end

Public Instance Methods

adapt_to_cmodel() click to toggle source

Override ActiveFedora::Core#adapt_to_cmodel (used with associations, among other places) to preferentially use the objectType asserted in the identityMetadata.

Calls superclass method
# File lib/dor/models/abstract.rb, line 58
def adapt_to_cmodel
  object_type = identityMetadata.objectType.first
  object_class = Dor.registered_classes[object_type]

  if object_class
    instance_of?(object_class) ? self : adapt_to(object_class)
  else
    begin
      super
    rescue ActiveFedora::ModelNotAsserted
      adapt_to(Dor::Item)
    end
  end
end
add_collection(collection_or_druid) click to toggle source
# File lib/dor/models/abstract.rb, line 90
def add_collection(collection_or_druid)
  collection_manager.add(collection_or_druid)
end
current_version() click to toggle source
# File lib/dor/models/abstract.rb, line 73
def current_version
  versionMetadata.current_version_id
end
read_rights=(rights) click to toggle source
# File lib/dor/models/abstract.rb, line 85
def read_rights=(rights)
  rightsMetadata.set_read_rights(rights)
  unshelve_and_unpublish if rights == 'dark'
end
reapply_admin_policy_object_defaults() click to toggle source

set the rights metadata datastream to the content of the APO's default object rights

# File lib/dor/models/abstract.rb, line 99
def reapply_admin_policy_object_defaults
  rightsMetadata.content = admin_policy_object.defaultObjectRights.content
end
remove_collection(collection_or_druid) click to toggle source
# File lib/dor/models/abstract.rb, line 94
def remove_collection(collection_or_druid)
  collection_manager.remove(collection_or_druid)
end
to_solr() click to toggle source

Overrides the method in ActiveFedora

# File lib/dor/models/abstract.rb, line 52
def to_solr
  raise 'this should never be called'
end

Private Instance Methods

collection_manager() click to toggle source
# File lib/dor/models/abstract.rb, line 109
def collection_manager
  CollectionService.new(self)
end
unshelve_and_unpublish() click to toggle source
# File lib/dor/models/abstract.rb, line 105
def unshelve_and_unpublish
  contentMetadata.unshelve_and_unpublish if respond_to? :contentMetadata
end