Class: Rigor::SigGen::MethodCandidate
- Inherits:
-
Object
- Object
- Rigor::SigGen::MethodCandidate
- Defined in:
- lib/rigor/sig_gen/method_candidate.rb
Overview
Per-method record produced by the generator.
‘classification` is one of the Classification constants; the remaining fields are populated only when applicable to that classification.
-
‘path` — the source `.rb` file the def came from.
-
‘class_name` — qualified receiver class name (e.g. `“Foo::Bar”`). `nil` for top-level / DSL-block defs the MVP skips.
-
‘method_name` — the def’s ‘Symbol` name.
-
‘kind` — `:instance` or `:singleton`.
-
‘inferred_return` — `Rigor::Type` instance (or `nil` when the inference pass disqualified the def).
-
‘declared_return_rbs` — the existing RBS-declared return spelling, or `nil` when no RBS declares the method.
-
‘rbs` — the rendered RBS one-liner the generator would emit (`nil` for skipped / equivalent rows).
-
‘skip_reason` — one of Classification::SKIP_DIAGNOSTIC_IDS keys when classification is `:skipped`, else `nil`.
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#class_shells ⇒ Object
readonly
Returns the value of attribute class_shells.
-
#classification ⇒ Object
readonly
Returns the value of attribute classification.
-
#declared_return_rbs ⇒ Object
readonly
Returns the value of attribute declared_return_rbs.
-
#inferred_return ⇒ Object
readonly
Returns the value of attribute inferred_return.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#namespace_kinds ⇒ Object
readonly
Returns the value of attribute namespace_kinds.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#rbs ⇒ Object
readonly
Returns the value of attribute rbs.
-
#skip_reason ⇒ Object
readonly
Returns the value of attribute skip_reason.
Instance Method Summary collapse
-
#initialize(path:, class_name:, method_name:, kind:, classification:, inferred_return: nil, declared_return_rbs: nil, rbs: nil, skip_reason: nil, namespace_kinds: {}, class_shells: []) ⇒ MethodCandidate
constructor
rubocop:disable Metrics/ParameterLists.
- #to_h ⇒ Object
Constructor Details
#initialize(path:, class_name:, method_name:, kind:, classification:, inferred_return: nil, declared_return_rbs: nil, rbs: nil, skip_reason: nil, namespace_kinds: {}, class_shells: []) ⇒ MethodCandidate
rubocop:disable Metrics/ParameterLists
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 30 def initialize(path:, class_name:, method_name:, kind:, classification:, # rubocop:disable Metrics/ParameterLists inferred_return: nil, declared_return_rbs: nil, rbs: nil, skip_reason: nil, namespace_kinds: {}, class_shells: []) @path = path @class_name = class_name @method_name = method_name @kind = kind @classification = classification @inferred_return = inferred_return @declared_return_rbs = declared_return_rbs @rbs = rbs @skip_reason = skip_reason @namespace_kinds = namespace_kinds.freeze @class_shells = class_shells.freeze freeze end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def class_name @class_name end |
#class_shells ⇒ Object (readonly)
Returns the value of attribute class_shells.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def class_shells @class_shells end |
#classification ⇒ Object (readonly)
Returns the value of attribute classification.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def classification @classification end |
#declared_return_rbs ⇒ Object (readonly)
Returns the value of attribute declared_return_rbs.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def declared_return_rbs @declared_return_rbs end |
#inferred_return ⇒ Object (readonly)
Returns the value of attribute inferred_return.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def inferred_return @inferred_return end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def kind @kind end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def method_name @method_name end |
#namespace_kinds ⇒ Object (readonly)
Returns the value of attribute namespace_kinds.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def namespace_kinds @namespace_kinds end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def path @path end |
#rbs ⇒ Object (readonly)
Returns the value of attribute rbs.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def rbs @rbs end |
#skip_reason ⇒ Object (readonly)
Returns the value of attribute skip_reason.
26 27 28 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def skip_reason @skip_reason end |
Instance Method Details
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 47 def to_h { file: path, class: class_name, method: method_name.to_s, kind: kind.to_s, classification: classification.to_s, rbs: rbs, inferred_return: inferred_return&.erase_to_rbs, declared_return_rbs: declared_return_rbs, skip_reason: skip_reason ? Classification::SKIP_DIAGNOSTIC_IDS.fetch(skip_reason) : nil }.compact end |