Module: Apes::Model
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/apes/model.rb
Overview
Some utility extensions to ActiveModel.
Instance Method Summary collapse
-
#additional_errors ⇒ ActiveModel::Errors
A list of manually managed errors for the model.
-
#all_validation_errors ⇒ ActiveModel::Errors
A list of automatically and manually added errors for the model.
-
#run_validations! ⇒ Object
Perform validations on the model and makes sure manually added errors are included.
Instance Method Details
#additional_errors ⇒ ActiveModel::Errors
A list of manually managed errors for the model.
69 70 71 |
# File 'lib/apes/model.rb', line 69 def additional_errors @additional_errors ||= ActiveModel::Errors.new(self) end |
#all_validation_errors ⇒ ActiveModel::Errors
A list of automatically and manually added errors for the model.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/apes/model.rb', line 82 def all_validation_errors additional_errors.each do |field, error| errors.add(field, error) end errors.each do |field| errors[field].uniq! end errors end |
#run_validations! ⇒ Object
Perform validations on the model and makes sure manually added errors are included.
74 75 76 77 |
# File 'lib/apes/model.rb', line 74 def run_validations! errors..merge!(additional_errors.) super end |