Class: Ohm::ActiveModelInterface::Errors
- Inherits:
-
Object
- Object
- Ohm::ActiveModelInterface::Errors
- Defined in:
- lib/ohm/contrib/active_model_extension.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #full_messages ⇒ Object
-
#initialize(scope, errors) ⇒ Errors
constructor
A new instance of Errors.
Constructor Details
#initialize(scope, errors) ⇒ Errors
Returns a new instance of Errors.
63 64 65 66 67 68 69 70 |
# File 'lib/ohm/contrib/active_model_extension.rb', line 63 def initialize(scope, errors) @scope = scope @errors = Hash.new { |hash, key| hash[key] = [] } errors.each do |key, value| @errors[key] << value end end |
Instance Method Details
#[](key) ⇒ Object
72 73 74 |
# File 'lib/ohm/contrib/active_model_extension.rb', line 72 def [](key) @errors[key] end |
#full_messages ⇒ Object
76 77 78 79 80 |
# File 'lib/ohm/contrib/active_model_extension.rb', line 76 def @errors.map do |key, value| I18n::t("ohm.%s.%s.%s" % [@scope, key, value]) end end |