Module: PactBroker::Messages
- Extended by:
- Messages
- Included in:
- Api::Resources::BaseResource, Api::Resources::CanIDeploy, Api::Resources::DeployedVersion, Api::Resources::ErrorResponseGenerator, Api::Resources::Pact, Api::Resources::ReleasedVersion, Contracts::Service, DB::ValidateEncoding, Domain::Pacticipant, Domain::Webhook, PactBroker::Matrix::Service, Messages, Pacticipants::Service, Pacts::Service, Pacts::VerifiablePactMessages, UI::ViewDomain::MatrixLine, Versions::BranchService, Versions::Service, Webhooks::Service, Webhooks::WebhookRequestTemplate, Rack::PactBroker::InvalidUriProtection
- Defined in:
- lib/pact_broker/messages.rb
Overview
Provides an interface to the I18n library specifically for the PactBroker’s messages.
Instance Method Summary collapse
-
#message(key, options = {}) ⇒ String
Interpolates an internationalized string.
- #pluralize(word, count) ⇒ Object
- #validation_message(key, options = {}) ⇒ Object
- #validation_message_at_index(key, index, options = {}) ⇒ Object
Instance Method Details
#message(key, options = {}) ⇒ String
Interpolates an internationalized string.
18 19 20 |
# File 'lib/pact_broker/messages.rb', line 18 def (key, ={}) ::I18n.t(key, **{ :scope => :pact_broker }.merge()) end |
#pluralize(word, count) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pact_broker/messages.rb', line 30 def pluralize(word, count) if count == 1 word else if word.end_with?("y") word.chomp("y") + "ies" else word + "s" end end end |
#validation_message(key, options = {}) ⇒ Object
22 23 24 |
# File 'lib/pact_broker/messages.rb', line 22 def key, = {} ("errors.validation." + key, ) end |
#validation_message_at_index(key, index, options = {}) ⇒ Object
26 27 28 |
# File 'lib/pact_broker/messages.rb', line 26 def key, index, = {} ("errors.validation." + key, ).chomp(".") + " (at index #{index})" end |