Class: PactBroker::Pacts::Content
- Inherits:
-
Object
- Object
- PactBroker::Pacts::Content
- Defined in:
- lib/pact_broker/pacts/content.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#content_that_affects_verification_results ⇒ Object
Half thinking this belongs in GenerateSha.
-
#initialize(pact_hash) ⇒ Content
constructor
A new instance of Content.
- #interactions ⇒ Object
- #messages ⇒ Object
- #pact_specification_version ⇒ Object
- #sort ⇒ Object
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(pact_hash) ⇒ Content
Returns a new instance of Content.
8 9 10 |
# File 'lib/pact_broker/pacts/content.rb', line 8 def initialize pact_hash @pact_hash = pact_hash end |
Class Method Details
.from_hash(pact_hash) ⇒ Object
16 17 18 |
# File 'lib/pact_broker/pacts/content.rb', line 16 def self.from_hash pact_hash new(pact_hash) end |
Instance Method Details
#content_that_affects_verification_results ⇒ Object
Half thinking this belongs in GenerateSha
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pact_broker/pacts/content.rb', line 33 def content_that_affects_verification_results if interactions || cont = {} cont['interactions'] = interactions if interactions cont['messages'] = if cont['pact_specification_version'] = pact_specification_version if pact_specification_version cont else pact_hash end end |
#interactions ⇒ Object
49 50 51 |
# File 'lib/pact_broker/pacts/content.rb', line 49 def interactions pact_hash.is_a?(Hash) ? pact_hash['interactions'] : nil end |
#messages ⇒ Object
45 46 47 |
# File 'lib/pact_broker/pacts/content.rb', line 45 def pact_hash.is_a?(Hash) ? pact_hash['messages'] : nil end |
#pact_specification_version ⇒ Object
53 54 55 56 57 58 |
# File 'lib/pact_broker/pacts/content.rb', line 53 def pact_specification_version maybe_pact_specification_version_1 = pact_hash['metadata']['pactSpecification']['version'] rescue nil maybe_pact_specification_version_2 = pact_hash['metadata']['pact-specification']['version'] rescue nil maybe_pact_specification_version_3 = pact_hash['metadata'] && pact_hash['metadata']['pactSpecificationVersion'] rescue nil maybe_pact_specification_version_1 || maybe_pact_specification_version_2 || maybe_pact_specification_version_3 end |
#sort ⇒ Object
28 29 30 |
# File 'lib/pact_broker/pacts/content.rb', line 28 def sort Content.from_hash(SortContent.call(pact_hash)) end |
#to_hash ⇒ Object
20 21 22 |
# File 'lib/pact_broker/pacts/content.rb', line 20 def to_hash pact_hash end |
#to_json ⇒ Object
24 25 26 |
# File 'lib/pact_broker/pacts/content.rb', line 24 def to_json pact_hash.to_json end |