Class: Riffer::Guardrails::Modification

Inherits:
Object
  • Object
show all
Defined in:
lib/riffer/guardrails/modification.rb,
sig/generated/riffer/guardrails/modification.rbs

Overview

Records a guardrail transformation event.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(guardrail:, phase:, message_indices:) ⇒ Modification

-- : (guardrail: singleton(Riffer::Guardrail), phase: Symbol, message_indices: Array) -> void

Parameters:

  • guardrail: (singleton(Riffer::Guardrail))
  • phase: (Symbol)
  • message_indices: (Array[Integer])


17
18
19
20
21
# File 'lib/riffer/guardrails/modification.rb', line 17

def initialize(guardrail:, phase:, message_indices:)
  @guardrail = guardrail
  @phase = phase
  @message_indices = message_indices
end

Instance Attribute Details

#guardrailsingleton(Riffer::Guardrail) (readonly)

The guardrail class that transformed data.

Returns:



7
8
9
# File 'lib/riffer/guardrails/modification.rb', line 7

def guardrail
  @guardrail
end

#message_indicesArray[Integer] (readonly)

The indices of messages that were changed.

Returns:

  • (Array[Integer])


13
14
15
# File 'lib/riffer/guardrails/modification.rb', line 13

def message_indices
  @message_indices
end

#phaseSymbol (readonly)

The phase when the transformation occurred (:before or :after).

Returns:

  • (Symbol)


10
11
12
# File 'lib/riffer/guardrails/modification.rb', line 10

def phase
  @phase
end

Instance Method Details

#to_hHash[Symbol, untyped]

Converts the modification to a hash.

-- : () -> Hash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


27
28
29
30
31
32
33
# File 'lib/riffer/guardrails/modification.rb', line 27

def to_h
  {
    guardrail: guardrail.name,
    phase: phase,
    message_indices: message_indices
  }
end