Sha256: a4e7e75fa6e49dc7585f995c7f378752aebf0a8f2ec79e12f0e3f40ea874370d

Contents?: true

Size: 407 Bytes

Versions: 3

Compression:

Stored size: 407 Bytes

Contents

# frozen_string_literal: true

module Hashtastic
  class Digester
    class << self
      def call(dictionary, filter = [])
        dictionary = filter.empty? ? dictionary : extractor(dictionary, filter)

        URI.encode_www_form(dictionary.to_a.sort)
      end

      private

      def extractor(dictionary, filter)
        dictionary.with_indifferent_access.slice(*filter)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hashtastic-0.3.1 lib/hashtastic/digester.rb
hashtastic-0.3.0 lib/hashtastic/digester.rb
hashtastic-0.2.0 lib/hashtastic/digester.rb