Class: Rivendell::Import::CartFinder::ByApi

Inherits:
Rivendell::Import::CartFinder show all
Defined in:
lib/rivendell/import/cart_finder.rb

Constant Summary collapse

@@time_to_live =
600

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Rivendell::Import::CartFinder

#default_normalizer, #find_all_by_title, #find_by_title

Constructor Details

#initialize(xport) ⇒ ByApi



33
34
35
# File 'lib/rivendell/import/cart_finder.rb', line 33

def initialize(xport)
  @xport = xport
end

Instance Attribute Details

#purged_atObject

Returns the value of attribute purged_at.



49
50
51
# File 'lib/rivendell/import/cart_finder.rb', line 49

def purged_at
  @purged_at
end

#xportObject

Returns the value of attribute xport.



31
32
33
# File 'lib/rivendell/import/cart_finder.rb', line 31

def xport
  @xport
end

Instance Method Details

#cacheObject



37
38
39
40
# File 'lib/rivendell/import/cart_finder.rb', line 37

def cache
  clear if purged_at < time_to_live.ago
  @cache ||= {}
end

#carts(options = {}) ⇒ Object



55
56
57
# File 'lib/rivendell/import/cart_finder.rb', line 55

def carts(options = {})
  cache[options.to_s] ||= xport.list_carts(options)
end

#clearObject



42
43
44
# File 'lib/rivendell/import/cart_finder.rb', line 42

def clear
  @cache = nil
end