Module: PactBroker::Messages
- Extended by:
- Messages
- Included in:
- Api::Contracts::CanIDeployQuerySchema, Api::Contracts::EnvironmentSchema, Api::Contracts::PacticipantNameContract, Api::Contracts::PacticipantNameValidation, Api::Contracts::PacticipantSchema, Api::Contracts::PactsForVerificationJSONQuerySchema, Api::Contracts::PublishContractsSchema, Api::Resources::CanIDeploy, Api::Resources::DeployedVersion, Api::Resources::Pact, Api::Resources::ReleasedVersion, Contracts::Service, DB::ValidateEncoding, Domain::Pacticipant, Domain::Webhook, PactBroker::Matrix::Service, Messages, Pacts::Service, Pacts::VerifiablePactMessages, UI::ViewDomain::MatrixLine, 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
- #potential_duplicate_pacticipant_message(new_name, potential_duplicate_pacticipants, base_url) ⇒ Object
- #validation_message(key, 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
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pact_broker/messages.rb', line 35 def pluralize(word, count) if count == 1 word else if word.end_with?("y") word.chomp("y") + "ies" else word + "s" end end end |
#potential_duplicate_pacticipant_message(new_name, potential_duplicate_pacticipants, base_url) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/pact_broker/messages.rb', line 26 def new_name, potential_duplicate_pacticipants, base_url existing_names = potential_duplicate_pacticipants. collect{ | p | "* #{p.name}" }.join("\n") ("errors.duplicate_pacticipant", new_name: new_name, existing_names: existing_names, create_pacticipant_url: pacticipants_url(base_url)) end |
#validation_message(key, options = {}) ⇒ Object
22 23 24 |
# File 'lib/pact_broker/messages.rb', line 22 def key, = {} ("errors.validation." + key, ) end |