class PactBroker::Pacts::SortContent
Public Class Methods
call(pact_hash)
click to toggle source
TODO handle interactions and messages at the same time
# File lib/pact_broker/pacts/sort_content.rb, line 10 def self.call pact_hash key = verifiable_content_key_for(pact_hash) if key content = pact_hash[key] sorted_pact_hash = order_hash_keys(pact_hash) sorted_pact_hash[key] = order_verifiable_content(content) sorted_pact_hash else pact_hash end end
order_verifiable_content(probably_array)
click to toggle source
# File lib/pact_broker/pacts/sort_content.rb, line 33 def self.order_verifiable_content probably_array # You never can tell what people will do... if probably_array.is_a?(Array) array_with_ordered_hashes = order_hash_keys(probably_array) array_with_ordered_hashes.sort_by(&:to_json) else probably_array end end
verifiable_content_key_for(pact_hash)
click to toggle source
# File lib/pact_broker/pacts/sort_content.rb, line 23 def self.verifiable_content_key_for pact_hash if pact_hash["interactions"] "interactions" elsif pact_hash["messages"] "messages" else nil end end