Sha256: 452955948a98ffb1b2a1c367782972a22ef190b1469b779f0991a7e1ced97123

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

# Copyright © 2012 The Pennsylvania State University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'hydra/model_methods'
module Sufia
  module ModelMethods
    extend ActiveSupport::Concern

    included do
      include Hydra::ModelMethods
    end

    # 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.

    def apply_depositor_metadata(depositor_id)
      rights_ds = self.datastreams["rightsMetadata"]
      prop_ds = self.datastreams["properties"]

      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

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

  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
sufia-3.0.0 sufia-models/lib/sufia/models/model_methods.rb
sufia-models-3.0.0 lib/sufia/models/model_methods.rb
sufia-2.0.1 sufia-models/lib/sufia/models/model_methods.rb
sufia-models-2.0.1 lib/sufia/models/model_methods.rb
sufia-2.0.0 sufia-models/lib/sufia/models/model_methods.rb
sufia-models-2.0.0 lib/sufia/models/model_methods.rb
sufia-models-0.1.2 lib/sufia/models/model_methods.rb
sufia-models-0.1.1 lib/sufia/models/model_methods.rb
sufia-1.3.0 lib/sufia/model_methods.rb