class DigestHash
Public Class Methods
call(params)
click to toggle source
# File lib/digest_hash.rb, line 5 def self.call(params) new(params).cache_key end
new(params)
click to toggle source
# File lib/digest_hash.rb, line 9 def initialize(params) @params = params end
Public Instance Methods
cache_key()
click to toggle source
# File lib/digest_hash.rb, line 13 def cache_key Digest::MD5.hexdigest(cleaned_params) end
cleaned_params()
click to toggle source
# File lib/digest_hash.rb, line 17 def cleaned_params @cleaned_params = @params remove_nulls deeply_sort_and_stringify_values stringify_keys sort_and_stringify_hash end
deeply_sort_and_stringify_values()
click to toggle source
# File lib/digest_hash.rb, line 32 def deeply_sort_and_stringify_values @cleaned_params = @cleaned_params.deep_merge(@cleaned_params) do |_, _, val| if val.is_a? Array val.sort.to_s else val.to_s end end end
remove_nulls()
click to toggle source
# File lib/digest_hash.rb, line 26 def remove_nulls @cleaned_params = @cleaned_params.to_h.delete_if do |_, val| val.nil? || val.try(:empty?) end end
sort_and_stringify_hash()
click to toggle source
# File lib/digest_hash.rb, line 46 def sort_and_stringify_hash @cleaned_params = @cleaned_params.sort.to_s end
stringify_keys()
click to toggle source
# File lib/digest_hash.rb, line 42 def stringify_keys @cleaned_params = @cleaned_params.deep_stringify_keys end