Sha256: f544679c9208843a789dbfe0d80c036b44379be3e4b80c33c960c870d361d35d

Contents?: true

Size: 618 Bytes

Versions: 67

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

67 entries across 67 versions & 1 rubygems

Version Path
pact_broker-2.79.1 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.79.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.78.1 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.78.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.77.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.76.2 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.76.1 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.76.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.75.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.74.1 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.74.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.73.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.72.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.71.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.70.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.69.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.68.1 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.68.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.67.0 lib/pact_broker/pacts/order_hash_keys.rb
pact_broker-2.66.0 lib/pact_broker/pacts/order_hash_keys.rb