Class: MDOT::ExceptionKey
- Inherits:
-
Object
- Object
- MDOT::ExceptionKey
- Defined in:
- lib/mdot/exceptions/key.rb
Instance Attribute Summary collapse
-
#i18n_key ⇒ Object
readonly
Returns the value of attribute i18n_key.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key) ⇒ ExceptionKey
constructor
A new instance of ExceptionKey.
- #key_exists?(key) ⇒ Boolean private
- #validate_key(key) ⇒ Object private
Constructor Details
#initialize(key) ⇒ ExceptionKey
Returns a new instance of ExceptionKey.
7 8 9 10 11 |
# File 'lib/mdot/exceptions/key.rb', line 7 def initialize(key) @default_exception = 'default_exception' @key = validate_key(key) @i18n_key = "mdot.exceptions.#{@key}" end |
Instance Attribute Details
#i18n_key ⇒ Object (readonly)
Returns the value of attribute i18n_key.
5 6 7 |
# File 'lib/mdot/exceptions/key.rb', line 5 def i18n_key @i18n_key end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/mdot/exceptions/key.rb', line 5 def key @key end |
Instance Method Details
#key_exists?(key) ⇒ Boolean (private)
15 16 17 |
# File 'lib/mdot/exceptions/key.rb', line 15 def key_exists?(key) I18n.exists?("mdot.exceptions.#{key}") end |
#validate_key(key) ⇒ Object (private)
19 20 21 |
# File 'lib/mdot/exceptions/key.rb', line 19 def validate_key(key) key.present? && key_exists?(key) ? key : @default_exception end |