class Riffer::Guardrails::Tripwire
Captures information about a blocked guardrail execution.
Constants
- PHASES
Attributes
The guardrail class that triggered the block.
Optional metadata about the block.
The phase when the block occurred (:before or :after).
The reason for blocking.
Public Class Methods
Source
# File lib/riffer/guardrails/tripwire.rb, line 23 def initialize(reason:, guardrail:, phase:, metadata: nil) raise Riffer::ArgumentError, "Invalid phase: #{phase}" unless PHASES.include?(phase) @reason = reason @guardrail = guardrail @phase = phase @metadata = metadata end
Raises Riffer::ArgumentError if phase is invalid.
Public Instance Methods
Source
# File lib/riffer/guardrails/tripwire.rb, line 36 def to_h { reason: reason, guardrail: guardrail.name, phase: phase, metadata: metadata } end
Converts the tripwire to a hash.