Class: Rigor::Inference::ProjectPatchedMethods
- Inherits:
-
Object
- Object
- Rigor::Inference::ProjectPatchedMethods
- Defined in:
- lib/rigor/inference/project_patched_methods.rb
Overview
ADR-17 § "Inference contract" — project-wide patched-method registry populated by the pre-eval
pre-pass (slice 2) from the user's .rigor.yml pre_eval: list.
Each entry records one def declaration the pre-pass observed inside a class / module body. The
dispatcher's try_project_patched_method tier consults this registry between the plugin tier and
the dependency-source tier so project-side lib/core_ext/string_extensions.rb patches are visible
to cross-file dispatch.
The dispatcher answers Dynamic[T] (with a heuristic static facet) when Entry#return_type is
non-nil, or Dynamic[Top] when the heuristic declined (nil). See Entry for the per-field
contract.
Defined Under Namespace
Classes: Entry
Constant Summary collapse
- EMPTY =
new.freeze
Instance Attribute Summary collapse
-
#by_key ⇒ Object
readonly
Returns the value of attribute by_key.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(entries: []) ⇒ ProjectPatchedMethods
constructor
A new instance of ProjectPatchedMethods.
-
#lookup(class_name:, method_name:, kind:) ⇒ Entry?
The recorded entry for the given
(class_name, method_name, kind)triple, ornilwhen no pre-eval file declared it.
Constructor Details
#initialize(entries: []) ⇒ ProjectPatchedMethods
Returns a new instance of ProjectPatchedMethods.
34 35 36 37 38 39 40 |
# File 'lib/rigor/inference/project_patched_methods.rb', line 34 def initialize(entries: []) @by_key = entries.each_with_object({}) do |entry, acc| key = [entry.class_name, entry.method_name, entry.kind] acc[key] ||= entry end.freeze freeze end |
Instance Attribute Details
#by_key ⇒ Object (readonly)
Returns the value of attribute by_key.
29 30 31 |
# File 'lib/rigor/inference/project_patched_methods.rb', line 29 def by_key @by_key end |
Instance Method Details
#empty? ⇒ Boolean
48 49 50 |
# File 'lib/rigor/inference/project_patched_methods.rb', line 48 def empty? @by_key.empty? end |
#lookup(class_name:, method_name:, kind:) ⇒ Entry?
Returns the recorded entry for the given (class_name, method_name, kind) triple,
or nil when no pre-eval file declared it.
44 45 46 |
# File 'lib/rigor/inference/project_patched_methods.rb', line 44 def lookup(class_name:, method_name:, kind:) @by_key[[class_name, method_name, kind]] end |