Module: PactBroker::Api::Resources::BadgeMethods
- Included in:
- Badge, CanIDeployPacticipantVersionByBranchToEnvironmentBadge, CanIDeployPacticipantVersionByTagToTagBadge, CanIMergeBadge
- 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
- #set_cache_control(cache_control_str) ⇒ Object
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
45 46 47 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 45 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 43 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 34 def moved_temporarily? set_cache_control("no-cache") begin badge_url rescue StandardError => e # Want to render a badge, even if there's an error error_reference = log_and_report_error(e) badge_service.error_badge_url("error", "reference: #{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 |
#set_cache_control(cache_control_str) ⇒ Object
49 50 51 |
# File 'lib/pact_broker/api/resources/badge_methods.rb', line 49 def set_cache_control(cache_control_str) response.headers["Cache-Control"] = cache_control_str end |