Sha256: c0ed8516de97f45bc554e34d438643b343bad14cbf9288e0d20ea92209711978

Contents?: true

Size: 573 Bytes

Versions: 36

Compression:

Stored size: 573 Bytes

Contents

require 'active_resource'

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

    # 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

36 entries across 36 versions & 1 rubygems

Version Path
ddr-core-1.13.2 app/models/ddr/auxiliary_resource.rb
ddr-core-1.13.1 app/models/ddr/auxiliary_resource.rb
ddr-core-1.13.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.12.2 app/models/ddr/auxiliary_resource.rb
ddr-core-1.12.1 app/models/ddr/auxiliary_resource.rb
ddr-core-1.12.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.11.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.10.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.9.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.8.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.7.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.6.6 app/models/ddr/auxiliary_resource.rb
ddr-core-1.6.5 app/models/ddr/auxiliary_resource.rb
ddr-core-1.6.4 app/models/ddr/auxiliary_resource.rb
ddr-core-1.6.3 app/models/ddr/auxiliary_resource.rb
ddr-core-1.6.2 app/models/ddr/auxiliary_resource.rb
ddr-core-1.6.1 app/models/ddr/auxiliary_resource.rb
ddr-core-1.6.0 app/models/ddr/auxiliary_resource.rb
ddr-core-1.5.5 app/models/ddr/auxiliary_resource.rb
ddr-core-1.5.4 app/models/ddr/auxiliary_resource.rb