Class: Riffer::Guardrails::Modification
- Inherits:
-
Object
- Object
- Riffer::Guardrails::Modification
- Defined in:
- lib/riffer/guardrails/modification.rb
Overview
Records a guardrail transformation event.
When a guardrail transforms data (via transform), a Modification is created to record which guardrail made the change, in which phase, and which message indices were affected.
Instance Attribute Summary collapse
-
#guardrail ⇒ Object
readonly
The guardrail class that transformed data.
-
#message_indices ⇒ Object
readonly
The indices of messages that were changed.
-
#phase ⇒ Object
readonly
The phase when the transformation occurred (:before or :after).
Instance Method Summary collapse
-
#initialize(guardrail:, phase:, message_indices:) ⇒ Modification
constructor
Creates a new modification record.
-
#to_h ⇒ Object
Converts the modification to a hash.
Constructor Details
#initialize(guardrail:, phase:, message_indices:) ⇒ Modification
Creates a new modification record.
- guardrail
-
the guardrail class that transformed.
- phase
-
:before or :after.
- message_indices
-
indices of changed messages.
– : (guardrail: singleton(Riffer::Guardrail), phase: Symbol, message_indices: Array) -> void
27 28 29 30 31 |
# File 'lib/riffer/guardrails/modification.rb', line 27 def initialize(guardrail:, phase:, message_indices:) @guardrail = guardrail @phase = phase @message_indices = end |
Instance Attribute Details
#guardrail ⇒ Object (readonly)
The guardrail class that transformed data.
11 12 13 |
# File 'lib/riffer/guardrails/modification.rb', line 11 def guardrail @guardrail end |
#message_indices ⇒ Object (readonly)
The indices of messages that were changed.
17 18 19 |
# File 'lib/riffer/guardrails/modification.rb', line 17 def @message_indices end |
#phase ⇒ Object (readonly)
The phase when the transformation occurred (:before or :after).
14 15 16 |
# File 'lib/riffer/guardrails/modification.rb', line 14 def phase @phase end |
Instance Method Details
#to_h ⇒ Object
Converts the modification to a hash.
– : () -> Hash[Symbol, untyped]
37 38 39 40 41 42 43 |
# File 'lib/riffer/guardrails/modification.rb', line 37 def to_h { guardrail: guardrail.name, phase: phase, message_indices: } end |