Sha256: 2e48d69ce78b6c0a811856aa01e707b689f1c9407bd5a8f54046dbc3a8fc6be7
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
module ThreeScaleToolbox module Helper class << self def compare_hashes(first, second, keys) keys.map { |key| first.fetch(key, nil) } == keys.map { |key| second.fetch(key, nil) } end ## # Compute array difference with custom comparator def array_difference(ary, other_ary) ary.reject do |ary_elem| other_ary.find do |other_ary_elem| yield(ary_elem, other_ary_elem) end end end ## # Returns new hash object with not nil valid params def filter_params(valid_params, source) valid_params.each_with_object({}) do |key, target| target[key] = source[key] unless source[key].nil? end end def parse_uri(uri) # raises error when remote_str is not string, but object or something else. uri_obj = URI(uri) # URI::HTTP is parent of URI::HTTPS # with single check both types are checked raise ThreeScaleToolbox::InvalidUrlError, "invalid url: #{uri}" unless uri_obj.kind_of?(URI::HTTP) uri_obj end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
3scale_toolbox-0.7.0 | lib/3scale_toolbox/helper.rb |
3scale_toolbox-0.6.0 | lib/3scale_toolbox/helper.rb |