Sha256: 50a1c8c62d69318b84ddd326bb02d760b46a811197c1963c927295eabf44a625

Contents?: true

Size: 890 Bytes

Versions: 1

Compression:

Stored size: 890 Bytes

Contents

module CachedResource
  # The Model module is included in ActiveResource::Base and
  # provides methods to enable caching and manipulate the caching
  # configuration
  module Model
    extend ActiveSupport::Concern

    included do
      class << self
        attr_accessor :cached_resource

        # initialize cached resource or retrieve the current cached resource configuration
        def cached_resource(options={})
          defined?(@cached_resource) && @cached_resource || setup_cached_resource!(options)
        end

        # setup cached resource for this class by creating a new configuration
        # and establishing the necessary methods.
        def setup_cached_resource!(options)
          @cached_resource = CachedResource::Configuration.new(options)
          send :include, CachedResource::Caching
          @cached_resource
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cached_resource-2.0.1 lib/cached_resource/cached_resource.rb