Class: Cash::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/cash/local.rb

Instance Method Summary collapse

Constructor Details

#initialize(remote_cache) ⇒ Local

Returns a new instance of Local.



5
6
7
# File 'lib/cash/local.rb', line 5

def initialize(remote_cache)
  @remote_cache = remote_cache
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



16
17
18
# File 'lib/cash/local.rb', line 16

def method_missing(method, *args, &block)
  @remote_cache.send(method, *args, &block)
end

Instance Method Details

#cache_locallyObject



9
10
11
12
13
14
# File 'lib/cash/local.rb', line 9

def cache_locally
  @remote_cache = LocalBuffer.new(original_cache = @remote_cache)
  yield
ensure
  @remote_cache = original_cache
end