Class: PactBroker::Api::Resources::LatestPact
- Inherits:
-
BaseResource
- Object
- BaseResource
- PactBroker::Api::Resources::LatestPact
- Defined in:
- lib/pact_broker/api/resources/latest_pact.rb
Instance Method Summary collapse
- #allowed_methods ⇒ Object
- #content_types_provided ⇒ Object
- #metadata ⇒ Object
- #pact ⇒ Object
- #policy_name ⇒ Object
- #resource_exists? ⇒ Boolean
- #to_extended_json ⇒ Object
- #to_html ⇒ Object
- #to_json ⇒ Object
Instance Method Details
#allowed_methods ⇒ Object
19 20 21 |
# File 'lib/pact_broker/api/resources/latest_pact.rb', line 19 def allowed_methods ["GET", "OPTIONS"] end |
#content_types_provided ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/pact_broker/api/resources/latest_pact.rb', line 10 def content_types_provided [ ["application/hal+json", :to_json], ["application/json", :to_json], ["text/html", :to_html], ["application/vnd.pactbrokerextended.v1+json", :to_extended_json] ] end |
#metadata ⇒ Object
52 53 54 |
# File 'lib/pact_broker/api/resources/latest_pact.rb', line 52 def @metadata ||= (PactBroker::Pacts::Metadata.(pact, identifier_from_path)) end |
#pact ⇒ Object
48 49 50 |
# File 'lib/pact_broker/api/resources/latest_pact.rb', line 48 def pact @pact ||= pact_service.find_latest_pact(identifier_from_path) end |
#policy_name ⇒ Object
27 28 29 |
# File 'lib/pact_broker/api/resources/latest_pact.rb', line 27 def policy_name :'pacts::pact' end |
#resource_exists? ⇒ Boolean
23 24 25 |
# File 'lib/pact_broker/api/resources/latest_pact.rb', line 23 def resource_exists? !!pact end |
#to_extended_json ⇒ Object
36 37 38 |
# File 'lib/pact_broker/api/resources/latest_pact.rb', line 36 def to_extended_json decorator_class(:extended_pact_decorator).new(pact).to_json((metadata: )) end |
#to_html ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/pact_broker/api/resources/latest_pact.rb', line 40 def to_html PactBroker.configuration.html_pact_renderer.call( pact, { base_url: ui_base_url, badge_url: "#{resource_url}/badge.svg" }) end |
#to_json ⇒ Object
31 32 33 34 |
# File 'lib/pact_broker/api/resources/latest_pact.rb', line 31 def to_json response.headers["X-Pact-Consumer-Version"] = pact.consumer_version_number decorator_class(:pact_decorator).new(pact).to_json((metadata: )) end |