Class: Rigor::SigGen::ObservedCall

Inherits:
Object
  • Object
show all
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 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

Class Method Summary collapse

Instance Method Summary collapse

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

#keywordObject (readonly)

Returns the value of attribute keyword.



19
20
21
# File 'lib/rigor/sig_gen/observed_call.rb', line 19

def keyword
  @keyword
end

#positionalObject (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

Returns:

  • (Boolean)


27
28
29
# File 'lib/rigor/sig_gen/observed_call.rb', line 27

def empty?
  positional.empty? && keyword.empty?
end

#hashObject



36
37
38
# File 'lib/rigor/sig_gen/observed_call.rb', line 36

def hash
  [ObservedCall, positional, keyword].hash
end