Class: ActiveModel::NestedError

Inherits:
Error show all
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

Attributes inherited from Error

#raw_type

Instance Method Summary collapse

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, 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

Instance Attribute Details

#attributeSymbol (readonly)

Returns attribute of the object which the error belongs to.

Returns:

  • (Symbol)

    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, 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

#baseActiveModel::Base (readonly)

Returns the object which the error belongs to.

Returns:

  • (ActiveModel::Base)

    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, 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

#inner_errorError (readonly)

Returns inner error.

Returns:

  • (Error)

    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, 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

#optionsHash (readonly)

Returns additional options.

Returns:

  • (Hash)

    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, 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

#typeSymbol (readonly)

Returns error's type.

Returns:


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, 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