Class: Outlander::Agent
- Inherits:
-
Object
- Object
- Outlander::Agent
- Includes:
- HTTParty
- Defined in:
- lib/outlander/agent.rb
Class Attribute Summary collapse
-
.cache_storage ⇒ Object
Returns the value of attribute cache_storage.
Class Method Summary collapse
Class Attribute Details
.cache_storage ⇒ Object
Returns the value of attribute cache_storage.
10 11 12 |
# File 'lib/outlander/agent.rb', line 10 def cache_storage @cache_storage end |
Class Method Details
.fetch(path, options = {}, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/outlander/agent.rb', line 13 def self.fetch(path, = {}, &block) if cache_enabled? && [:cache] response_body = @cache_storage.get(path) || get(path, , &block).body @cache_storage.set(path, response_body) response_body else get(path, , &block).body end end |
.method_missing(m, *args, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/outlander/agent.rb', line 23 def self.method_missing(m, *args, &block) if m.to_s.end_with? '_with_cache' if cache_enabled? response_body = @cache_storage.get(args[0]) || get(*args, &block).body @cache_storage.set(args[0], response_body) response_body else get(*args, &block).body end end end |