Class: Pact::ConsumerContract::Message::Contents

Inherits:
Object
  • Object
show all
Includes:
ActiveSupportSupport, SymbolizeKeys
Defined in:
lib/pact/consumer_contract/message/contents.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Contents

Returns a new instance of Contents.



14
15
16
# File 'lib/pact/consumer_contract/message/contents.rb', line 14

def initialize contents
  @contents = contents
end

Class Method Details

.from_hash(contents, options = {}) ⇒ Object

Could technically be an array



10
11
12
# File 'lib/pact/consumer_contract/message/contents.rb', line 10

def self.from_hash contents, options = {}
  new(contents)
end

Instance Method Details

#as_jsonObject



38
39
40
# File 'lib/pact/consumer_contract/message/contents.rb', line 38

def as_json
  @contents
end

#contentsObject



34
35
36
# File 'lib/pact/consumer_contract/message/contents.rb', line 34

def contents
  @contents
end

#reified_contents_stringObject



26
27
28
29
30
31
32
# File 'lib/pact/consumer_contract/message/contents.rb', line 26

def reified_contents_string
  if contents.is_a?(Hash) || contents.is_a?(Array)
    Pact::Reification.from_term(contents).to_json
  else
    Pact::Reification.from_term(contents).to_s
  end
end

#to_sObject



18
19
20
21
22
23
24
# File 'lib/pact/consumer_contract/message/contents.rb', line 18

def to_s
  if contents.is_a?(Hash) || contents.is_a?(Array)
    contents.to_json
  else
    contents.to_s
  end
end