Class: Yes::Core::ErrorMessages
- Inherits:
-
Object
- Object
- Yes::Core::ErrorMessages
- Defined in:
- lib/yes/core/error_messages.rb
Overview
Helper class for looking up error messages from I18n
Class Method Summary collapse
-
.guard_error(context_name, aggregate_name, command_name, guard_name) ⇒ String
Looks up the error message for a guard from I18n translations.
Class Method Details
.guard_error(context_name, aggregate_name, command_name, guard_name) ⇒ String
Looks up the error message for a guard from I18n translations
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/yes/core/error_messages.rb', line 15 def guard_error(context_name, aggregate_name, command_name, guard_name) context_key, aggregate_key, command_key, guard_key = normalize_keys( context_name, aggregate_name, command_name, guard_name ) # Try to find the error message in the following order: # 1. Specific translation for this aggregate attribute guard # 2. Default fallback message I18n.t( "aggregates.#{context_key}.#{aggregate_key}.commands.#{command_key}.guards.#{guard_key}.error", default: "Guard '#{guard_key}' failed" ) end |