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` of positional types only) could not represent keyword arguments — every call like `MethodCatalog.new(path: …, mutating_selectors: …)` discarded the whole observation via `non_positional?`. 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 of `Rigor::Type` per positional argument, in call-site order.
-
‘keyword` — frozen Hash mapping each keyword argument’s Symbol name to its ‘Rigor::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 ‘ObservedCall` carrier.
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.
29 30 31 32 33 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 29 def initialize(positional: [], keyword: {}) @positional = positional.freeze @keyword = keyword.freeze freeze end |
Instance Attribute Details
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
27 28 29 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 27 def keyword @keyword end |
#positional ⇒ Object (readonly)
Returns the value of attribute positional.
27 28 29 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 27 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.
53 54 55 56 57 58 59 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 53 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?
39 40 41 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 39 def ==(other) other.is_a?(ObservedCall) && positional == other.positional && keyword == other.keyword end |
#empty? ⇒ Boolean
35 36 37 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 35 def empty? positional.empty? && keyword.empty? end |
#hash ⇒ Object
44 45 46 |
# File 'lib/rigor/sig_gen/observed_call.rb', line 44 def hash [ObservedCall, positional, keyword].hash end |