Module: Sufia::ModelMethods

Extended by:
ActiveSupport::Concern
Included in:
Batch, Collection, GenericFile
Defined in:
app/models/concerns/sufia/model_methods.rb

Instance Method Summary collapse

Instance Method Details

#apply_depositor_metadata(depositor) ⇒ Object

OVERRIDE to support Hydra::Datastream::Properties which does not

respond to :depositor_values but :depositor

Adds metadata about the depositor to the asset Most important behavior: if the asset has a rightsMetadata datastream, this method will add depositor_id to its individual edit permissions.



14
15
16
17
18
19
20
21
22
23
# File 'app/models/concerns/sufia/model_methods.rb', line 14

def (depositor)
  rights_ds = self.datastreams["rightsMetadata"]
  prop_ds = self.datastreams["properties"]
  depositor_id = depositor.respond_to?(:user_key) ? depositor.user_key : depositor

  rights_ds.update_indexed_attributes([:edit_access, :person]=>depositor_id) unless rights_ds.nil?
  prop_ds.depositor = depositor_id unless prop_ds.nil?

  return true
end

#to_sObject



25
26
27
28
# File 'app/models/concerns/sufia/model_methods.rb', line 25

def to_s
  return Array(title).join(" | ") if title.present?
  label || "No Title"
end