Class: PactBroker::Pacts::ResolvedSelector
- Inherits:
-
Selector
- Object
- Hash
- Selector
- PactBroker::Pacts::ResolvedSelector
show all
- Defined in:
- lib/pact_broker/pacts/selector.rb
Constant Summary
collapse
- PROPERTY_NAMES =
Selector::PROPERTY_NAMES + [:consumer_version, :environment, :target]
Instance Method Summary
collapse
Methods inherited from Selector
all_for_tag, #all_for_tag?, all_for_tag_and_consumer, #all_for_tag_and_consumer?, #branch, #branch=, #consumer, #consumer=, #currently_deployed, #currently_deployed=, #currently_deployed?, #currently_supported, #currently_supported=, #currently_supported?, #environment_name, #environment_name=, #fallback_branch, #fallback_branch=, #fallback_branch?, #fallback_tag, #fallback_tag=, #fallback_tag?, #for_consumer, for_currently_deployed, for_currently_deployed_and_consumer, for_currently_deployed_and_environment_and_consumer, for_currently_supported, for_currently_supported_and_environment_and_consumer, for_environment, for_environment_and_consumer, for_main_branch, from_hash, #in_environment?, #latest, #latest=, latest_for_branch, #latest_for_branch?, latest_for_branch_and_consumer, latest_for_branch_with_fallback, latest_for_consumer, #latest_for_each_branch?, #latest_for_main_branch?, latest_for_tag, #latest_for_tag?, latest_for_tag_and_consumer, latest_for_tag_with_fallback, #main_branch, #main_branch=, #matching_branch, #matching_branch=, #matching_branch?, overall_latest, #overall_latest?, #resolve, #resolve_for_environment, #resolve_for_fallback, #tag, #tag=, #type
Constructor Details
#initialize(properties = {}, consumer_version) ⇒ ResolvedSelector
Returns a new instance of ResolvedSelector.
386
387
388
389
|
# File 'lib/pact_broker/pacts/selector.rb', line 386
def initialize(properties = {}, consumer_version)
properties.without(*PROPERTY_NAMES).tap { |it| warn("WARN: Unsupported property for #{self.class.name}: #{it.keys.join(", ")} at #{caller[0..3]}") if it.any? }
merge!(properties.merge(consumer_version: consumer_version))
end
|
Instance Method Details
#<=>(other) ⇒ Object
403
404
405
406
407
408
409
410
|
# File 'lib/pact_broker/pacts/selector.rb', line 403
def <=> other
comparison = super
if comparison == 0
consumer_version.order <=> other.consumer_version.order
else
comparison
end
end
|
#==(other) ⇒ Object
399
400
401
|
# File 'lib/pact_broker/pacts/selector.rb', line 399
def == other
super && consumer_version == other.consumer_version
end
|
#consumer_version ⇒ Object
391
392
393
|
# File 'lib/pact_broker/pacts/selector.rb', line 391
def consumer_version
self[:consumer_version]
end
|
#currently_deployed_comparison(other) ⇒ Object
412
413
414
415
416
417
418
419
|
# File 'lib/pact_broker/pacts/selector.rb', line 412
def currently_deployed_comparison(other)
if currently_deployed? == other.currently_deployed?
production_comparison(other)
else
currently_deployed? ? -1 : 1
end
end
|
#currently_supported_comparison(other) ⇒ Object
421
422
423
424
425
426
427
|
# File 'lib/pact_broker/pacts/selector.rb', line 421
def currently_supported_comparison(other)
if currently_supported? == other.currently_supported?
production_comparison(other)
else
currently_supported? ? -1 : 1
end
end
|
#environment ⇒ Object
395
396
397
|
# File 'lib/pact_broker/pacts/selector.rb', line 395
def environment
self[:environment]
end
|
#production_comparison(other) ⇒ Object
429
430
431
432
433
434
435
|
# File 'lib/pact_broker/pacts/selector.rb', line 429
def production_comparison(other)
if environment.production? == other.environment.production?
environment.name <=> other.environment.name
else
environment.production? ? 1 : -1
end
end
|