Module: Assertion::Messages
- Included in:
- Base
- Defined in:
- lib/assertion/messages.rb
Overview
Module Messages provides a feature for gem-specific translation of messages describing the desired state of the assertion
You need to declare a hash of attributes to be added to the translation.
Constant Summary collapse
- ROOT =
The gem-specific root scope for translations
:assertion- DICTIONARY =
The states to be translated with their dictionary names
{ true => :right, false => :wrong }
Instance Method Summary collapse
- #attributes ⇒ Object
-
#message(state) ⇒ String
Returns the message describing the desired state of assertion.
Instance Method Details
#attributes ⇒ Object
59 60 61 |
# File 'lib/assertion/messages.rb', line 59 def attributes {} end |
#message(state) ⇒ String
Returns the message describing the desired state of assertion
The translation is provided for the gem-specific scope for the current class
51 52 53 54 55 56 |
# File 'lib/assertion/messages.rb', line 51 def (state) key = DICTIONARY[state] scope = [ROOT, Inflector[:to_snake_path][self.class.name]] I18n.translate key, attributes.merge(scope: scope) end |