Class: Rivendell::Import::CartFinder::ByApi
- Inherits:
-
Rivendell::Import::CartFinder
- Object
- Rivendell::Import::CartFinder
- Rivendell::Import::CartFinder::ByApi
- Defined in:
- lib/rivendell/import/cart_finder.rb
Constant Summary collapse
- @@time_to_live =
600
Instance Attribute Summary collapse
-
#purged_at ⇒ Object
Returns the value of attribute purged_at.
-
#xport ⇒ Object
Returns the value of attribute xport.
Instance Method Summary collapse
- #cache ⇒ Object
- #carts(options = {}) ⇒ Object
- #clear ⇒ Object
-
#initialize(xport) ⇒ ByApi
constructor
A new instance of ByApi.
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_at ⇒ Object
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 |
#xport ⇒ Object
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
#cache ⇒ Object
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( = {}) cache[.to_s] ||= xport.list_carts() end |
#clear ⇒ Object
42 43 44 |
# File 'lib/rivendell/import/cart_finder.rb', line 42 def clear @cache = nil end |