Class: ActiveModel::NestedError
- Extended by:
- Forwardable
- Defined in:
- activemodel/lib/active_model/nested_error.rb
Overview
Represents one single error
Constant Summary
Constants inherited from Error
Error::CALLBACKS_OPTIONS, Error::MESSAGE_OPTIONS
Instance Attribute Summary collapse
-
#attribute ⇒ Symbol
readonly
Attribute of the object which the error belongs to.
-
#base ⇒ ActiveModel::Base
readonly
The object which the error belongs to.
-
#inner_error ⇒ Error
readonly
Inner error.
-
#options ⇒ Hash
readonly
Additional options.
-
#type ⇒ Symbol
readonly
Error’s type.
Attributes inherited from Error
Instance Method Summary collapse
-
#initialize(base, inner_error, override_options = {}) ⇒ NestedError
constructor
A new instance of NestedError.
Methods inherited from Error
#==, #detail, #full_message, full_message, generate_message, #hash, #initialize_dup, #match?, #message, #strict_match?
Constructor Details
#initialize(base, inner_error, override_options = {}) ⇒ NestedError
Returns a new instance of NestedError.
19 20 21 22 23 24 25 26 |
# File 'activemodel/lib/active_model/nested_error.rb', line 19 def initialize(base, inner_error, = {}) @base = base @inner_error = inner_error @attribute = .fetch(:attribute) { inner_error.attribute } @type = .fetch(:type) { inner_error.type } @raw_type = inner_error.raw_type @options = inner_error. end |
Instance Attribute Details
#attribute ⇒ Symbol (readonly)
Returns attribute of the object which the error belongs to.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'activemodel/lib/active_model/nested_error.rb', line 18 class NestedError < Error def initialize(base, inner_error, = {}) @base = base @inner_error = inner_error @attribute = .fetch(:attribute) { inner_error.attribute } @type = .fetch(:type) { inner_error.type } @raw_type = inner_error.raw_type @options = inner_error. end attr_reader :inner_error extend Forwardable def_delegators :@inner_error, :message end |
#base ⇒ ActiveModel::Base (readonly)
Returns the object which the error belongs to.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'activemodel/lib/active_model/nested_error.rb', line 18 class NestedError < Error def initialize(base, inner_error, = {}) @base = base @inner_error = inner_error @attribute = .fetch(:attribute) { inner_error.attribute } @type = .fetch(:type) { inner_error.type } @raw_type = inner_error.raw_type @options = inner_error. end attr_reader :inner_error extend Forwardable def_delegators :@inner_error, :message end |
#inner_error ⇒ Error (readonly)
Returns inner error.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'activemodel/lib/active_model/nested_error.rb', line 18 class NestedError < Error def initialize(base, inner_error, = {}) @base = base @inner_error = inner_error @attribute = .fetch(:attribute) { inner_error.attribute } @type = .fetch(:type) { inner_error.type } @raw_type = inner_error.raw_type @options = inner_error. end attr_reader :inner_error extend Forwardable def_delegators :@inner_error, :message end |
#options ⇒ Hash (readonly)
Returns additional options.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'activemodel/lib/active_model/nested_error.rb', line 18 class NestedError < Error def initialize(base, inner_error, = {}) @base = base @inner_error = inner_error @attribute = .fetch(:attribute) { inner_error.attribute } @type = .fetch(:type) { inner_error.type } @raw_type = inner_error.raw_type @options = inner_error. end attr_reader :inner_error extend Forwardable def_delegators :@inner_error, :message end |
#type ⇒ Symbol (readonly)
Returns error’s type.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'activemodel/lib/active_model/nested_error.rb', line 18 class NestedError < Error def initialize(base, inner_error, = {}) @base = base @inner_error = inner_error @attribute = .fetch(:attribute) { inner_error.attribute } @type = .fetch(:type) { inner_error.type } @raw_type = inner_error.raw_type @options = inner_error. end attr_reader :inner_error extend Forwardable def_delegators :@inner_error, :message end |