Sha256: dc60cf610fa95e470a33f42e8661a3030be50a7e17b7247c438416474009b16f

Contents?: true

Size: 689 Bytes

Versions: 1

Compression:

Stored size: 689 Bytes

Contents

module RestrictCache
  class Base
    class << self
      def instance
        _cache = RestrictCache.custom_cache.contents(cache_key)
        _cache = RestrictCache.custom_cache.add(self.new) unless _cache
        _cache
      end

      def cache_key
        self.name
      end

      private
        def method_missing(name, *args, &block)
          super unless instance.respond_to?(name)

          define_singleton_method(name) do |*a, &b|
            instance.public_send(name, *a, &b)
          end

          send(name, *args, &block)
        end

        def respond_to_missing?(name, include_private = false)
          instance.respond_to?(name)
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restrict_cache-0.1.2 lib/restrict_cache/base.rb