class ViolationError
Raised when an object is accessed from a different fiber than the one that owns it.
Definitions
def initialize(message = nil, target:, method:, owner:, current:)
Initialize a new violation error.
Signature
-
parameter
messageString | Nil Optional custom message.
-
parameter
targetObject The object that was accessed.
-
parameter
methodSymbol The method that was called.
-
parameter
ownerFiber The fiber that owns the object.
-
parameter
currentFiber The fiber that attempted to access the object.
Implementation
def initialize(message = nil, target:, method:, owner:, current:)
@target = target
@method = method
@owner = owner
@current = current
super(message || build_message)
end
def as_json
Convert the violation error to a JSON-serializable hash.
Signature
-
returns
Hash A hash representation of the violation.
Implementation
def as_json
{
object_class: @object_class,
method: @method,
owner: {
name: @owner.inspect,
backtrace: @owner.backtrace,
},
current: {
name: @current.inspect,
backtrace: @current.backtrace,
},
}
end