Module: RestrictCache::Accessible
- Included in:
- RestrictCache
- Defined in:
- lib/restrict_cache/accessible.rb
Constant Summary
collapse
- THREAD_KEY =
:restrict_cache
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/restrict_cache/accessible.rb', line 13
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)
end
send(name, *args, &block)
end
|
Instance Method Details
#cache ⇒ Object
5
6
7
|
# File 'lib/restrict_cache/accessible.rb', line 5
def cache
Thread.current[THREAD_KEY] ||= Cacheable.new
end
|
#clear ⇒ Object
9
10
11
|
# File 'lib/restrict_cache/accessible.rb', line 9
def clear
Thread.current[THREAD_KEY] = nil
end
|