Module: RubyBase::Cache

Defined in:
lib/ruby_base/cache.rb

Class Method Summary collapse

Class Method Details

.proxy(method, route, block, params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruby_base/cache.rb', line 6

def self.proxy(method, route, block, params)
  if [:POST,:PUT,:DELETE].include?(method)
    @data = {}
    return Yajl::Encoder.encode(block.call(params))
  else
    temp = "#{route}-#{method}"
    ret = @data[temp]
    if ret
      return ret
    else
      response = Yajl::Encoder.encode(block.call(params))
      @data[temp] = response
      return response
    end
  end
end