lib/restrict_cache/accessible.rb in restrict_cache-0.1.1 vs lib/restrict_cache/accessible.rb in restrict_cache-0.1.2

- old
+ new

@@ -1,25 +1,30 @@ module RestrictCache module Accessible THREAD_KEY = :restrict_cache def cache - Thread.current[THREAD_KEY] ||= Cacheable.new + Thread.current[THREAD_KEY] ||= CacheCollection.new end def clear Thread.current[THREAD_KEY] = nil end - def method_missing(name, *args, &block) - super unless cache.respond_to?(name) + private + def method_missing(name, *args, &block) + super unless cache.respond_to?(name) - define_singleton_method(name) do |*a, &b| - cache.public_send(name, *a, &b) + define_singleton_method(name) do |*a, &b| + cache.public_send(name, *a, &b) + end + + send(name, *args, &block) end - send(name, *args, &block) - end + def respond_to_missing?(name, include_private = false) + cache.respond_to?(name) + end end extend Accessible end