Sha256: 9d7349fe8954efa6e14c85cd09f1963a1cc45d7764f3a3539e76b14e8404fd9e

Contents?: true

Size: 666 Bytes

Versions: 4

Compression:

Stored size: 666 Bytes

Contents

require 'active_resource'

module Ddr
  #
  # Abstract superclass for resources bound to ddr-aux API data
  #
  class AuxiliaryResource < ActiveResource::Base

    warn '[DEPRECATION] Ddr::AuxiliaryResource is deprecated and will be removed from ddr-core 2.0'

    # ActiveResource freezes `site` in subclasses
    self.site = Ddr.ddr_aux_api_url

    class_attribute :cache_expiry, instance_accessor: false
    self.cache_expiry = 1.hour

    def self.fetch(value_key, &block)
      Rails.cache.fetch(cache_key(value_key), expires_in: cache_expiry, &block)
    end

    def self.cache_key(suffix)
      [ model_name.cache_key, suffix ].join('/')
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ddr-core-1.17.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.16.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.15.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.14.0 app/models/ddr/auxiliary_resource.rb