Module: HTTParty::Cache::ClassMethods

Defined in:
lib/httparty/cache.rb

Instance Method Summary collapse

Instance Method Details

#cache_control(cache_control) ⇒ Object

Sets cache_control



41
42
43
# File 'lib/httparty/cache.rb', line 41

def cache_control(cache_control)
  default_options[:cache_control] = cache_control
end

#cache_store(cache_store = nil) ⇒ HTTParty::Cache::Store::Abstract

This is both a setter and a getter…

Parameters:

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/httparty/cache.rb', line 18

def cache_store(cache_store = nil)
  case cache_store
  when NilClass
    return default_options[:cache_store]
  when Symbol
    require_relative "cache/store/#{cache_store}"

    class_name = cache_store.to_s.split('_').map(&:capitalize).join
    cache_store = Object.const_get("HTTParty::Cache::Store::#{class_name}").new
  end

  default_options[:cache_store] = cache_store
end

#caching(caching) ⇒ Bool

Toggle caching

Parameters:

  • :caching (Bool)

Returns:

  • (Bool)


36
37
38
# File 'lib/httparty/cache.rb', line 36

def caching(caching)
  default_options[:caching] = caching
end