Class: Dor::Abstract

Inherits:
ActiveFedora::Base
  • Object
show all
Defined in:
lib/dor/models/abstract.rb

Direct Known Subclasses

AdminPolicyObject, Etd, Item, Set

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.assign_pid(_obj) ⇒ Object

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



45
46
47
48
49
# 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) ⇒ Object



38
39
40
41
# File 'lib/dor/models/abstract.rb', line 38

def self.has_object_type(str)
  self.object_type = str
  Dor.registered_classes[str] = self
end

Instance Method Details

#adapt_to_cmodelObject

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



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/dor/models/abstract.rb', line 58

def adapt_to_cmodel
  object_type = .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) ⇒ Object



90
91
92
# File 'lib/dor/models/abstract.rb', line 90

def add_collection(collection_or_druid)
  collection_manager.add(collection_or_druid)
end

#current_versionObject



73
74
75
# File 'lib/dor/models/abstract.rb', line 73

def current_version
  .current_version_id
end

#read_rights=(rights) ⇒ Object



85
86
87
88
# File 'lib/dor/models/abstract.rb', line 85

def read_rights=(rights)
  .set_read_rights(rights)
  unshelve_and_unpublish if rights == 'dark'
end

#reapply_admin_policy_object_defaultsObject

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



99
100
101
# File 'lib/dor/models/abstract.rb', line 99

def reapply_admin_policy_object_defaults
  .content = admin_policy_object.defaultObjectRights.content
end

#remove_collection(collection_or_druid) ⇒ Object



94
95
96
# File 'lib/dor/models/abstract.rb', line 94

def remove_collection(collection_or_druid)
  collection_manager.remove(collection_or_druid)
end

#to_solrObject

Overrides the method in ActiveFedora



52
53
54
# File 'lib/dor/models/abstract.rb', line 52

def to_solr
  raise 'this should never be called'
end