Module: PactBroker::Api::Resources::BadgeMethods
- Included in:
- Badge, CanIDeployPacticipantVersionByBranchToEnvironmentBadge, CanIDeployPacticipantVersionByTagToTagBadge
- Defined in:
- lib/pact_broker/api/resources/badge_methods.rb
Instance Method Summary collapse
- #allowed_methods ⇒ Object
- #badge_url ⇒ Object
- #content_types_provided ⇒ Object
- #forbidden? ⇒ Boolean
- #is_authorized?(authorization_header) ⇒ Boolean
- #moved_temporarily? ⇒ Boolean
- #policy_name ⇒ Object
-
#previously_existed? ⇒ Boolean
Only called if resource_exists? returns false.
- #resource_exists? ⇒ Boolean
Instance Method Details
#allowed_methods ⇒ Object
5 6 7 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 5 def allowed_methods ["GET", "OPTIONS"] end |
#badge_url ⇒ Object
44 45 46 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 44 def badge_url raise NotImplementedError end |
#content_types_provided ⇒ Object
9 10 11 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 9 def content_types_provided [["image/svg+xml", :to_svg]] end |
#forbidden? ⇒ Boolean
22 23 24 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 22 def forbidden? false end |
#is_authorized?(authorization_header) ⇒ Boolean
26 27 28 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 26 def () super || PactBroker.configuration.enable_public_badge_access end |
#moved_temporarily? ⇒ Boolean
34 35 36 37 38 39 40 41 42 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 34 def moved_temporarily? response.headers["Cache-Control"] = "no-cache" begin badge_url rescue StandardError => e # Want to render a badge, even if there's an error badge_service.error_badge_url("error", ErrorResponseGenerator.(e, "reference: #{PactBroker::Errors.generate_error_reference}")) end end |
#policy_name ⇒ Object
30 31 32 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 30 def policy_name :'badges::badge' end |
#previously_existed? ⇒ Boolean
Only called if resource_exists? returns false
18 19 20 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 18 def previously_existed? true end |
#resource_exists? ⇒ Boolean
13 14 15 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 13 def resource_exists? false end |