Class: Cacho

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

Defined Under Namespace

Classes: Client, DB

Constant Summary collapse

VERSION =
"0.1.3"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Cacho

Returns a new instance of Cacho.



14
15
16
17
18
# File 'lib/cacho.rb', line 14

def initialize(*args)
  @client = Client.new(*args)
  @db = DB.new("~/.cacho/cache")
  @hasher = -> *args { args }
end

Instance Attribute Details

#hasherObject

Returns the value of attribute hasher.



12
13
14
# File 'lib/cacho.rb', line 12

def hasher
  @hasher
end

Instance Method Details

#request(verb, *args) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cacho.rb', line 20

def request(verb, *args)
  if verb == :get
    uri = @client.uri(*args)

    @db.get(verb, uri) do
      @client.request(verb, *args)
    end
  else
    @client.request(verb, *args)
  end
end