Sha256: 8fab90672063053eecdc3a9d56d3c72b455c13f828e5704f740fa492f0cdd06c

Contents?: true

Size: 618 Bytes

Versions: 44

Compression:

Stored size: 618 Bytes

Contents

require "pact_broker/json"

module PactBroker
  module Pacts
    module OrderHashKeys
      def self.call thing
        case thing
          when Hash then order_hash(thing)
          when Array then order_child_array(thing)
        else thing
        end
      end

      def self.order_child_array array
        array.collect{ |thing| call(thing) }
      end

      def self.order_hash hash
        hash.keys.sort.each_with_object({}) do | key, new_hash |
          new_hash[key] = call(hash[key])
        end
      end

      def order_hash_keys(thing)
        OrderHashKeys.call(thing)
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
pact_broker-2.112.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.111.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.109.1 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.109.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.108.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.107.1 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.107.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.107.0.beta.1 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.106.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.105.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.104.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.103.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.102.2 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.102.1 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.102.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.101.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.100.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.99.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.98.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.97.0 lib/pact_broker/pacts/order_hash_keys.rb