1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/lib/active_model/nested_error.rb
lulalala fcd1e41e82 Document on ActiveModel::Errors changes
Mark private constants

Display alternative for deprecation removal warning

Annotate Error's attributes

More emphasis on adding an error instead of message

Rewrite scaffold template using new errors API

Set first and last with behavior change deprecation

Update more doc and example

Add inspect for easier debugging
2020-01-14 23:55:09 +08:00

22 lines
579 B
Ruby

# frozen_string_literal: true
require "active_model/error"
require "forwardable"
module ActiveModel
class NestedError < Error
def initialize(base, inner_error, override_options = {})
@base = base
@inner_error = inner_error
@attribute = override_options.fetch(:attribute) { inner_error.attribute }
@type = override_options.fetch(:type) { inner_error.type }
@raw_type = inner_error.raw_type
@options = inner_error.options
end
attr_reader :inner_error
extend Forwardable
def_delegators :@inner_error, :message
end
end