Sha256: 0231264e0c7fdee03418ce3649e5b71347b52d637f03c735abb0037c933b8648

Contents?: true

Size: 1.01 KB

Versions: 27

Compression:

Stored size: 1.01 KB

Contents

module Ddr
  module Models
    module Licensable
      extend ActiveSupport::Concern

      included do
        has_attributes :license_title, datastream: Ddr::Datastreams::RIGHTS_METADATA, at: [:license, :title], multiple: false
        has_attributes :license_description, datastream: Ddr::Datastreams::RIGHTS_METADATA, at: [:license, :description], multiple: false
        has_attributes :license_url, datastream: Ddr::Datastreams::RIGHTS_METADATA, at: [:license, :url], multiple: false
      end

      def license
        if license_title.present? or license_description.present? or license_url.present?
          {title: license_title, description: license_description, url: license_url}.with_indifferent_access
        end
      end
  
      def license=(new_license)
        raise ArgumentError unless new_license.is_a?(Hash)
        l = new_license.with_indifferent_access
        self.license_title = l[:title]
        self.license_description = l[:description]
        self.license_url = l[:url]
      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ddr-models-1.13.2 lib/ddr/models/licensable.rb
ddr-models-1.13.1 lib/ddr/models/licensable.rb
ddr-models-1.13.0 lib/ddr/models/licensable.rb
ddr-models-1.11.8 lib/ddr/models/licensable.rb
ddr-models-1.12.3 lib/ddr/models/licensable.rb
ddr-models-1.11.7 lib/ddr/models/licensable.rb
ddr-models-1.12.2 lib/ddr/models/licensable.rb
ddr-models-1.11.6 lib/ddr/models/licensable.rb
ddr-models-1.12.1 lib/ddr/models/licensable.rb
ddr-models-1.11.5 lib/ddr/models/licensable.rb
ddr-models-1.12.0 lib/ddr/models/licensable.rb
ddr-models-1.11.4 lib/ddr/models/licensable.rb
ddr-models-1.11.3 lib/ddr/models/licensable.rb
ddr-models-1.11.2 lib/ddr/models/licensable.rb
ddr-models-1.11.1 lib/ddr/models/licensable.rb
ddr-models-1.11.0 lib/ddr/models/licensable.rb
ddr-models-1.10.0 lib/ddr/models/licensable.rb
ddr-models-1.9.0 lib/ddr/models/licensable.rb
ddr-models-1.8.1 lib/ddr/models/licensable.rb
ddr-models-1.8.0 lib/ddr/models/licensable.rb