Class: Restify::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/restify/cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(store) ⇒ Cache

Returns a new instance of Cache.



5
6
7
# File 'lib/restify/cache.rb', line 5

def initialize(store)
  @store = store
end

Instance Method Details

#call(request) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/restify/cache.rb', line 9

def call(request)
  if (response = match(request))
    return response
  end

  yield(request).then do |new_response|
    cache(new_response)
    new_response
  end
end