Module: HTTParty::Sober::ClassMethods
- Defined in:
- lib/httparty/sober.rb
Constant Summary collapse
- @@cache_store =
nil
- @@cache_options =
{}
Instance Method Summary collapse
- #cache(cache_options = {}) ⇒ Object
- #cache!(cache_options = {}) ⇒ Object
- #get_with_caching(path, options = {}) ⇒ Object
Instance Method Details
#cache(cache_options = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/httparty/sober.rb', line 11 def cache(={}) @@cache_store = .delete(:store) APICache.store = @@cache_store if @@cache_store @@cache_options = end |
#cache!(cache_options = {}) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/httparty/sober.rb', line 17 def cache!(={}) cache() self.instance_eval do alias :get_without_caching :get alias :get :get_with_caching end end |
#get_with_caching(path, options = {}) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/httparty/sober.rb', line 25 def get_with_caching(path, ={}) = (@@cache_options || {}).merge([:cache] || {}) APICache.get(path,) do perform_request(Net::HTTP::Get, path, ) end end |