Class: Cuprum::Rails::MapErrors
- Inherits:
-
Object
- Object
- Cuprum::Rails::MapErrors
- Defined in:
- lib/cuprum/rails/map_errors.rb
Overview
Maps errors from a validated Rails model to a Stannum::Errors object.
Class Method Summary collapse
-
.instance ⇒ MapErrors
A memoized instance of the class.
Instance Method Summary collapse
-
#call(native_errors:) ⇒ Stannum::Errors
Maps an ActiveModel::Errors object to a Stannum::Errors object.
Class Method Details
.instance ⇒ MapErrors
Returns a memoized instance of the class.
11 12 13 |
# File 'lib/cuprum/rails/map_errors.rb', line 11 def self.instance @instance ||= new end |
Instance Method Details
#call(native_errors:) ⇒ Stannum::Errors
Maps an ActiveModel::Errors object to a Stannum::Errors object.
20 21 22 23 24 25 26 27 |
# File 'lib/cuprum/rails/map_errors.rb', line 20 def call(native_errors:) unless native_errors.is_a?(ActiveModel::Errors) raise ArgumentError, 'native_errors must be an instance of ActiveModel::Errors' end map_errors(native_errors: native_errors) end |