Sha256: 09018454692b0135617d94e99edeb0a16283c0703fb1b8d5314844fde98d3cb6

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require File.expand_path('../../../validators/future_date_validator', __FILE__)
module CurationConcern
  module Embargoable
    extend ActiveSupport::Concern

    included do
      validates :embargo_release_date, future_date: true
      before_save :write_embargo_release_date, prepend: true
    end

    def write_embargo_release_date
      if defined?(@embargo_release_date)
        embargoable_persistence_container.embargo_release_date = embargo_release_date
      end
      true
    end
    protected :write_embargo_release_date

    def embargo_release_date=(value)
      @embargo_release_date = begin
        value.to_date
      rescue NoMethodError
        value
      end
    end

    def embargo_release_date
      @embargo_release_date || embargoable_persistence_container.embargo_release_date
    end

    if ! included_modules.include?('Morphine')
      require 'morphine'
      include Morphine
    end
    register :embargoable_persistence_container do
      if ! self.class.included_modules.include?('Sufia::GenericFile::Permissions')
        self.class.send(:include, Sufia::GenericFile::Permissions)
      end
      self.datastreams["rightsMetadata"]
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
curate-0.1.3 app/repository_models/curation_concern/embargoable.rb
curate-0.1.2 app/repository_models/curation_concern/embargoable.rb
curate-0.1.1 app/repository_models/curation_concern/embargoable.rb
curate-0.1.0 app/repository_models/curation_concern/embargoable.rb