Class: PactBroker::Domain::Pact

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/domain/pact.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Pact

Returns a new instance of Pact.



11
12
13
14
15
# File 'lib/pact_broker/domain/pact.rb', line 11

def initialize attributes
  attributes.each_pair do | key, value |
    self.send(key.to_s + "=", value)
  end
end

Instance Attribute Details

#consumerObject

Returns the value of attribute consumer.



9
10
11
# File 'lib/pact_broker/domain/pact.rb', line 9

def consumer
  @consumer
end

#consumer_versionObject

Returns the value of attribute consumer_version.



9
10
11
# File 'lib/pact_broker/domain/pact.rb', line 9

def consumer_version
  @consumer_version
end

#consumer_version_numberObject

Returns the value of attribute consumer_version_number.



9
10
11
# File 'lib/pact_broker/domain/pact.rb', line 9

def consumer_version_number
  @consumer_version_number
end

#created_atObject

Returns the value of attribute created_at.



9
10
11
# File 'lib/pact_broker/domain/pact.rb', line 9

def created_at
  @created_at
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/pact_broker/domain/pact.rb', line 9

def id
  @id
end

#json_contentObject

Returns the value of attribute json_content.



9
10
11
# File 'lib/pact_broker/domain/pact.rb', line 9

def json_content
  @json_content
end

#providerObject

Returns the value of attribute provider.



9
10
11
# File 'lib/pact_broker/domain/pact.rb', line 9

def provider
  @provider
end

#updated_atObject

Returns the value of attribute updated_at.



9
10
11
# File 'lib/pact_broker/domain/pact.rb', line 9

def updated_at
  @updated_at
end

Instance Method Details

#content_hashObject



37
38
39
# File 'lib/pact_broker/domain/pact.rb', line 37

def content_hash
  JSON.parse(json_content, PACT_PARSING_OPTIONS)
end

#nameObject



29
30
31
# File 'lib/pact_broker/domain/pact.rb', line 29

def name
  "Pact between #{consumer.name} (v#{consumer_version_number}) and #{provider.name}"
end

#to_json(options = {}) ⇒ Object



25
26
27
# File 'lib/pact_broker/domain/pact.rb', line 25

def to_json options = {}
  json_content
end

#to_sObject



21
22
23
# File 'lib/pact_broker/domain/pact.rb', line 21

def to_s
  "Pact: consumer=#{consumer.name} provider=#{provider.name}"
end

#version_and_updated_dateObject



33
34
35
# File 'lib/pact_broker/domain/pact.rb', line 33

def version_and_updated_date
  "Version #{consumer_version_number} - #{updated_at.to_time.localtime.strftime("%d/%m/%Y")}"
end