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.



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

def initialize contents
  @contents = contents
end

Class Method Details

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

Could technically be an array



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

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

Instance Method Details

#as_jsonObject



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

def as_json
  @contents
end

#contentsObject



25
26
27
# File 'lib/pact/consumer_contract/message/contents.rb', line 25

def contents
  @contents
end

#to_sObject



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

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