Class: Iry::StatementInvalid

Inherits:
ActiveRecord::StatementInvalid
  • Object
show all
Includes:
Error
Defined in:
lib/iry.rb

Overview

Raised when constraints errors happen and go through Iry, even if these are not handled. This class inherits from ActiveRecord::StatementInvalid to maximize compatibility with existing code

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, record:, error:, **kwargs) ⇒ StatementInvalid

Returns a new instance of StatementInvalid.

Parameters:

  • message (nil, String) (defaults to: nil)
  • record (Handlers::Model)
  • error (ActiveModel::Error)


71
72
73
74
75
# File 'lib/iry.rb', line 71

def initialize(message = nil, record:, error:, **kwargs)
  @record = record
  @error = error
  super(message, **kwargs)
end

Instance Attribute Details

#errorActiveModel::Error (readonly)

Returns error attached to the ‘record` for the constraint violation.

Returns:

  • (ActiveModel::Error)

    error attached to the ‘record` for the constraint violation



66
67
68
# File 'lib/iry.rb', line 66

def error
  @error
end

#recordHandlers::Model (readonly)

Returns model affected by the constraint violation.

Returns:



63
64
65
# File 'lib/iry.rb', line 63

def record
  @record
end