Class: CallMap::Resolver
- Inherits:
-
Object
- Object
- CallMap::Resolver
- Defined in:
- lib/call_map/resolver.rb
Overview
Resolves a MethodCall to a Definition using the SourceIndex.
This handles the common Rails patterns:
- bare call within the same class → instance method on
context_owner SomeService.execute→ class method on SomeServiceSomeClass.new(...).execute→ instance method on SomeClassself.foo→ class method oncontext_owner
Instance Method Summary collapse
-
#initialize(index) ⇒ Resolver
constructor
A new instance of Resolver.
- #resolve(call, context_owner:, context_kind: :instance_method, lexical_nesting: nil) ⇒ Definition?
Constructor Details
#initialize(index) ⇒ Resolver
Returns a new instance of Resolver.
13 14 15 |
# File 'lib/call_map/resolver.rb', line 13 def initialize(index) @index = index end |
Instance Method Details
#resolve(call, context_owner:, context_kind: :instance_method, lexical_nesting: nil) ⇒ Definition?
20 21 22 23 24 25 26 27 28 |
# File 'lib/call_map/resolver.rb', line 20 def resolve(call, context_owner:, context_kind: :instance_method, lexical_nesting: nil) return nil if call.dynamic? if call. || call.receiver == "self" (call, context_owner, context_kind) else resolve_receiver(call, context_owner, context_kind, lexical_nesting) end end |