Class: Rigor::SigGen::ObservedCall
- Inherits:
-
Object
- Object
- Rigor::SigGen::ObservedCall
- Defined in:
- lib/rigor/sig_gen/observed_call.rb
Overview
Per-call-site argument observation produced by ObservationCollector. ADR-14 follow-up: the earlier MVP
shape (Array[Type] of positional types only) could not represent keyword arguments — keyword calls like
MethodCatalog.new(path: ..., mutating_selectors: ...) were silently skipped in that shape. The new shape
carries positional and keyword arg types in parallel so the per-position / per-keyword unions can each be
reconstructed independently.
The carrier is intentionally minimal:
positional— frozen Array ofRigor::Typeper positional argument, in call-site order.keyword— frozen Hash mapping each keyword argument's Symbol name to itsRigor::Type.
Generator-side callers also accept a legacy shape (plain Array of types) for backward compatibility with
specs that constructed observations directly before this carrier existed; ObservedCall.from(...) does
the lift.
Instance Attribute Summary collapse
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#positional ⇒ Object
readonly
Returns the value of attribute positional.
Class Method Summary collapse
-
.from(value) ⇒ Object
Lifts the legacy plain-Array shape into an
ObservedCallcarrier.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #empty? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(positional: [], keyword: {}) ⇒ ObservedCall
constructor
A new instance of ObservedCall.
Constructor Details
#initialize(positional: [], keyword: {}) ⇒ ObservedCall
Returns a new instance of ObservedCall.
21 22 23 24 25 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 21 def initialize(positional: [], keyword: {}) @positional = positional.freeze @keyword = keyword.freeze freeze end |
Instance Attribute Details
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
19 20 21 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 19 def keyword @keyword end |
#positional ⇒ Object (readonly)
Returns the value of attribute positional.
19 20 21 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 19 def positional @positional end |
Class Method Details
.from(value) ⇒ Object
Lifts the legacy plain-Array shape into an ObservedCall carrier. Already-lifted values pass through
unchanged. Used by Generator#initialize's observations-normalisation pass so spec fixtures written
against the slice-3 surface keep working.
43 44 45 46 47 48 49 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 43 def self.from(value) case value when ObservedCall then value when Array then new(positional: value) else raise ArgumentError, "expected Array or ObservedCall, got #{value.class}" end end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
31 32 33 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 31 def ==(other) other.is_a?(ObservedCall) && positional == other.positional && keyword == other.keyword end |
#empty? ⇒ Boolean
27 28 29 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 27 def empty? positional.empty? && keyword.empty? end |
#hash ⇒ Object
36 37 38 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 36 def hash [ObservedCall, positional, keyword].hash end |