Module: CacheBar

Defined in:
lib/cachebar.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.register_api_to_cache(host, options) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
# File 'lib/cachebar.rb', line 18

def self.register_api_to_cache(host, options)
  raise ArgumentError, "You must provide a host that you are caching API responses for." if host.blank?

  missing_options = ([:expire_in, :key_name] - options.keys)
  if missing_options.present?
    raise(ArgumentError, "Missing some required options: #{missing_options.join(", ")}")
  end

  HTTParty::HTTPCache.apis[host] = options
end