Skip to content

Commit

Permalink
Fix HttpParty deprecation [DEPRECATION] HTTParty will no longer overr…
Browse files Browse the repository at this point in the history
…ide `response#nil?`. This functionality will be removed in future versions. Please, add explicit check `response.body.nil? || response.body.empty?`. For more info refer to: jnunemaker/httparty#568
  • Loading branch information
jmortlock committed Jun 1, 2020
1 parent 3f76b0f commit dbefa4b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/quick_travel/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ def self.cache(key, cache_options = nil)
cache_options ||= {}
key = "#{@@namespace}_#{key}" unless cache_options[:disable_namespacing]
cached_value = cache_store.read(key)
return cached_value unless cached_value.nil?
return cached_value unless cache_empty?(cached_value)
return nil unless block_given?
cache_options ||= {}
cache_options[:expires_in] = 1.day unless cache_options.key?(:expires_in)
yield.tap { |value| cache_store.write(key, value, cache_options) }
end

def self.cache_empty?(cached_value)
if cached_value.respond_to?(:body)
return cached_value.body.nil? || cached_value.body.empty?
end
cached_value.nil?
end

def self.delete(key, namespace = true)
key = "#{@@namespace}_#{key}" if namespace
cache_store.delete(key)
Expand Down

0 comments on commit dbefa4b

Please sign in to comment.