class PactBroker::Domain::Pact
Attributes
consumer[W]
consumer_version[RW]
The ID is the pact_publication ID
consumer_version_number[RW]
The ID is the pact_publication ID
created_at[RW]
The ID is the pact_publication ID
db_model[RW]
head_tag_names[RW]
The ID is the pact_publication ID
id[RW]
The ID is the pact_publication ID
json_content[RW]
The ID is the pact_publication ID
latest_verification[W]
pact_version_sha[RW]
The ID is the pact_publication ID
provider[RW]
The ID is the pact_publication ID
revision_number[RW]
The ID is the pact_publication ID
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 28 def initialize attributes = {} @latest_verification = UnsetAttribute.new attributes.each_pair do | key, value | self.send(key.to_s + "=", value) end end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 101 def <=> other self_fields = [consumer_name.downcase, provider_name.downcase, consumer_version.order || 0] other_fields = [other.consumer_name.downcase, other.provider_name.downcase, other.consumer_version.order || 0] self_fields <=> other_fields end
consumer()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 43 def consumer consumer_version.pacticipant end
consumer_name()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 35 def consumer_name consumer.name end
consumer_version_tag_names()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 47 def consumer_version_tag_names consumer_version.tags.collect(&:name) end
content_hash()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 75 def content_hash JSON.parse(json_content, PACT_PARSING_OPTIONS) end
content_object()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 79 def content_object @content_object ||= begin PactBroker::Pacts::Content.from_json(json_content) rescue PactBroker::Pacts::Content.new end end
latest_consumer_version_tag_names=(latest_consumer_version_tag_names)
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 51 def latest_consumer_version_tag_names= latest_consumer_version_tag_names @latest_consumer_version_tag_names = latest_consumer_version_tag_names end
latest_verification()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 55 def latest_verification get_attribute_if_set :latest_verification end
name()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 67 def name "Pact between #{consumer.name} (#{consumer_version_number}) and #{provider.name}" end
pact_publication_id()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 87 def pact_publication_id id end
pending?()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 97 def pending? !pact_version.verified_successfully_by_any_provider_version? end
provider_name()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 39 def provider_name provider.name end
to_json(_options = {})
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 63 def to_json _options = {} json_content end
to_s()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 59 def to_s "Pact: consumer=#{consumer.name} provider=#{provider.name}" end
version_and_updated_date()
click to toggle source
# File lib/pact_broker/domain/pact.rb, line 71 def version_and_updated_date "Version #{consumer_version_number} - #{created_at.to_time.localtime.strftime("%d/%m/%Y")}" end
Private Instance Methods
get_attribute_if_set(attribute_name)
click to toggle source
This class has various incarnations with different properties loaded. They should probably be different classes, but for now, raise an error if an attribute is called when it hasn't been set in the constuctor, because returning nil when there should be an object causes bugs.
# File lib/pact_broker/domain/pact.rb, line 121 def get_attribute_if_set attribute_name val = instance_variable_get("@#{attribute_name}".to_sym) if val.is_a?(UnsetAttribute) raise UnsetAttributeError.new("Attribute #{attribute_name} not set") else val end end
pact_version()
click to toggle source
Really not sure about mixing Sequel
model class into this PORO… But it's much nicer than using a repository to find out the pending information :(
# File lib/pact_broker/domain/pact.rb, line 113 def pact_version db_model.pact_version end