Sha256: 2a28cb13e09847f177bbad5eba371bbbdd9d14ed4a70bc4df69b058e59e9520b

Contents?: true

Size: 493 Bytes

Versions: 25

Compression:

Stored size: 493 Bytes

Contents

require "active_resource"

module Ddr::Models
  class License < ActiveResource::Base

    self.site = ENV["DDR_AUX_API_URL"]

    attr_accessor :pid

    def self.call(obj)
      if obj.license
        license = new get(:find, url: obj.license)
        license.pid = obj.pid
        license
      end
    rescue ActiveResource::ResourceNotFound => e
      raise Ddr::Models::NotFoundError, e
    end

    def self.keys
      all.map(&:url)
    end

    def to_s
      title
    end

  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
ddr-models-2.7.6 lib/ddr/models/licenses/license.rb
ddr-models-2.7.5 lib/ddr/models/licenses/license.rb
ddr-models-2.7.4 lib/ddr/models/licenses/license.rb
ddr-models-2.7.3 lib/ddr/models/licenses/license.rb
ddr-models-2.7.2 lib/ddr/models/licenses/license.rb
ddr-models-2.7.1 lib/ddr/models/licenses/license.rb
ddr-models-2.7.0 lib/ddr/models/licenses/license.rb
ddr-models-2.7.0.rc1 lib/ddr/models/licenses/license.rb
ddr-models-2.6.2 lib/ddr/models/licenses/license.rb
ddr-models-2.6.1 lib/ddr/models/licenses/license.rb
ddr-models-2.6.0 lib/ddr/models/licenses/license.rb
ddr-models-2.6.0.rc4 lib/ddr/models/licenses/license.rb
ddr-models-2.6.0.rc3 lib/ddr/models/licenses/license.rb
ddr-models-2.6.0.rc2 lib/ddr/models/licenses/license.rb
ddr-models-2.6.0.rc1 lib/ddr/models/licenses/license.rb
ddr-models-2.5.3 lib/ddr/models/licenses/license.rb
ddr-models-2.5.2 lib/ddr/models/licenses/license.rb
ddr-models-2.5.1 lib/ddr/models/licenses/license.rb
ddr-models-2.5.0 lib/ddr/models/licenses/license.rb
ddr-models-2.5.0.rc1 lib/ddr/models/licenses/license.rb