Sha256: a8cad6df79f12f4ecef2eadbc2c67d9f395a7b4e4ae6a26c970e2904cf06dde0

Contents?: true

Size: 1.4 KB

Versions: 8

Compression:

Stored size: 1.4 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
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
sufia-models-0.1.0 lib/sufia/models/model_methods.rb
sufia-models-0.0.2 lib/sufia/models/model_methods.rb
sufia-models-0.0.1 lib/sufia/models/model_methods.rb
sufia-1.2.0 lib/sufia/model_methods.rb
sufia-1.1.0 lib/sufia/model_methods.rb
sufia-1.0.0 lib/sufia/model_methods.rb
sufia-0.1.0 lib/sufia/model_methods.rb
sufia-0.0.8 lib/sufia/model_methods.rb