Class: Suitcase::Cache

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Cache) initialize(store)



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

def initialize(store)
  @store = store
end

Instance Attribute Details

- (Object) store

Returns the value of attribute store



3
4
5
# File 'lib/suitcase/cache.rb', line 3

def store
  @store
end

Instance Method Details

- (Boolean) cached?(action, params)



26
27
28
# File 'lib/suitcase/cache.rb', line 26

def cached?(action, params)
  @store[action] && @store[action][params]
end

- (Object) get_query(action, params)



18
19
20
# File 'lib/suitcase/cache.rb', line 18

def get_query(action, params)
  @store[action] ? @store[action][params] : nil
end

- (Object) keys



22
23
24
# File 'lib/suitcase/cache.rb', line 22

def keys
  @store.keys
end

- (Object) save_query(action, params, response)



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

def save_query(action, params, response)
  %w(apiKey cid customerSessionId customerIpAddress locale customerUserAgent).each do |param|
    params.delete(param)
  end
  params.delete("currencyCode") unless action == :paymentInfo
  @store[action] ||= {}
  @store[action][params] = response
end

- (Object) undefine_query(action, params)



30
31
32
# File 'lib/suitcase/cache.rb', line 30

def undefine_query(action, params)
  @store[action].delete(params) if @store[action]
end