Class: AdequateErrors::NestedError

Inherits:
Error
  • Object
show all
Defined in:
lib/adequate_errors/nested_error.rb

Overview

Represents one single error

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Error

#match?

Constructor Details

#initialize(base, inner_error, override_options = {}) ⇒ NestedError

Returns a new instance of NestedError.



14
15
16
17
18
19
20
# File 'lib/adequate_errors/nested_error.rb', line 14

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 }
  @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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/adequate_errors/nested_error.rb', line 13

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 }
    @options = inner_error.options
  end

  attr_reader :inner_error

  # Full message of the error.
  # Sourced from inner error.
  def message
    @inner_error.message
  end
end

#baseActiveModel::Base (readonly)

Returns the object which the error belongs to.

Returns:

  • (ActiveModel::Base)

    the object which the error belongs to



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/adequate_errors/nested_error.rb', line 13

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 }
    @options = inner_error.options
  end

  attr_reader :inner_error

  # Full message of the error.
  # Sourced from inner error.
  def message
    @inner_error.message
  end
end

#inner_errorError (readonly)

Returns inner error.

Returns:

  • (Error)

    inner error



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/adequate_errors/nested_error.rb', line 13

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 }
    @options = inner_error.options
  end

  attr_reader :inner_error

  # Full message of the error.
  # Sourced from inner error.
  def message
    @inner_error.message
  end
end

#optionsHash (readonly)

Returns additional options.

Returns:

  • (Hash)

    additional options



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/adequate_errors/nested_error.rb', line 13

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 }
    @options = inner_error.options
  end

  attr_reader :inner_error

  # Full message of the error.
  # Sourced from inner error.
  def message
    @inner_error.message
  end
end

#typeSymbol (readonly)

Returns error’s type.

Returns:

  • (Symbol)

    error’s type



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/adequate_errors/nested_error.rb', line 13

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 }
    @options = inner_error.options
  end

  attr_reader :inner_error

  # Full message of the error.
  # Sourced from inner error.
  def message
    @inner_error.message
  end
end

Instance Method Details

#messageObject

Full message of the error. Sourced from inner error.



26
27
28
# File 'lib/adequate_errors/nested_error.rb', line 26

def message
  @inner_error.message
end