class PactBroker::Domain::Pact
Attributes
The ID is the pact_publication ID
The ID is the pact_publication ID
The ID is the pact_publication ID
The ID is the pact_publication ID
The ID is the pact_publication ID
The ID is the pact_publication ID
The ID is the pact_publication ID
The ID is the pact_publication ID
The ID is the pact_publication ID
Public Class Methods
Source
# File lib/pact_broker/domain/pact.rb, line 31 def initialize attributes = {} @latest_verification = UnsetAttribute.new @consumer_version_tag_names = UnsetAttribute.new @consumer_version_branch_names = UnsetAttribute.new attributes.each_pair do | key, value | self.send(key.to_s + "=", value) end end
Public Instance Methods
Source
# File lib/pact_broker/domain/pact.rb, line 112 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
Source
# File lib/pact_broker/domain/pact.rb, line 48 def consumer @consumer || consumer_version.pacticipant end
Source
# File lib/pact_broker/domain/pact.rb, line 40 def consumer_name consumer.name end
Source
# File lib/pact_broker/domain/pact.rb, line 56 def consumer_version_branch_names get_attribute_if_set :consumer_version_branch_names end
Source
# File lib/pact_broker/domain/pact.rb, line 52 def consumer_version_tag_names get_attribute_if_set :consumer_version_tag_names end
Source
# File lib/pact_broker/domain/pact.rb, line 80 def content_hash JSON.parse(json_content, PACT_PARSING_OPTIONS) end
Source
# File lib/pact_broker/domain/pact.rb, line 84 def content_object @content_object ||= begin PactBroker::Pacts::Content.from_json(json_content) rescue PactBroker::Pacts::Content.new end end
Source
# File lib/pact_broker/domain/pact.rb, line 60 def latest_verification get_attribute_if_set :latest_verification end
Source
# File lib/pact_broker/domain/pact.rb, line 72 def name "Pact between #{consumer.name} (#{consumer_version_number}) and #{provider.name}" end
Source
# File lib/pact_broker/domain/pact.rb, line 92 def pact_publication_id id end
Source
# File lib/pact_broker/domain/pact.rb, line 108 def pending_for_any_provider_branch? !pact_version.verified_successfully_by_any_provider_version? end
Source
# File lib/pact_broker/domain/pact.rb, line 104 def pending_for_provider_branch?(branch_name) pact_version.pending_for_provider_branch?(branch_name) end
@param [String] branch_name the name of the provider branch that will be verifying the pacts @return Boolean whether or not the pact is in pending state (ie. the build should not fail if the verification fails)
Source
# File lib/pact_broker/domain/pact.rb, line 44 def provider_name provider.name end
Source
# File lib/pact_broker/domain/pact.rb, line 68 def to_json _options = {} json_content end
Source
# File lib/pact_broker/domain/pact.rb, line 64 def to_s "Pact: consumer=#{consumer.name} provider=#{provider.name}" end
Source
# File lib/pact_broker/domain/pact.rb, line 76 def version_and_updated_date "Version #{consumer_version_number} - #{created_at.to_time.localtime.strftime("%d/%m/%Y")}" end
Private Instance Methods
Source
# File lib/pact_broker/domain/pact.rb, line 132 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
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.
Source
# File lib/pact_broker/domain/pact.rb, line 124 def pact_version db_model.pact_version end
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 :(