Class: Solargraph::Pin::DelegatedMethod
- Defined in:
- lib/solargraph/pin/delegated_method.rb
Overview
A DelegatedMethod is a more complicated version of a MethodAlias that allows aliasing a method from a different closure (class/module etc).
Instance Attribute Summary
Attributes inherited from Method
#block, #documentation, #node, #signature_help, #signatures, #visibility
Attributes inherited from Callable
#block, #parameters, #return_type
Attributes inherited from Closure
Attributes inherited from Base
#code_object, #location, #name, #path, #return_type, #source, #type_location
Attributes included from Common
Instance Method Summary collapse
-
#initialize(method: nil, receiver: nil, name: method&.name, receiver_method_name: name, **splat) ⇒ DelegatedMethod
constructor
A DelegatedMethod can be constructed with either a :resolved_method pin, or a :receiver_chain.
- #resolvable?(api_map) ⇒ Boolean
Methods inherited from Method
#==, #all_rooted?, #anon_splat?, #attribute?, #block?, #completion_item_kind, #desc, #detail, #explicit?, #generate_signature, #nearly?, #overloads, #path, #probe, #resolve_ref_tag, #return_type, #symbol_kind, #to_rbs, #transform_types, #try_merge!, #typify, #with_single_signature
Methods inherited from Callable
#arity_matches?, #block?, #mandatory_positional_param_count, #parameter_names, #resolve_generics_from_context, #resolve_generics_from_context_until_complete, #to_rbs, #transform_types
Methods inherited from Closure
#binder, #context, #gates, #generics, #rbs_generics, #to_rbs
Methods inherited from Base
#==, #all_rooted?, #best_location, #comments, #completion_item_kind, #deprecated?, #desc, #directives, #docstring, #erase_generics, #filename, #identity, #infer, #inspect, #macros, #maybe_directives?, #nearly?, #presence_certain?, #probe, #probed?, #proxied?, #proxy, #realize, #resolve_generics, #resolve_generics_from_context, #symbol_kind, #to_rbs, #to_s, #transform_types, #try_merge!, #type_desc, #typify, #variable?
Methods included from Documenting
#documentation, normalize_indentation, strip_html_comments
Methods included from Conversions
#completion_item, #completion_item_kind, #deprecated?, #detail, #link_documentation, #probed?, #proxied?, #reset_conversions, #resolve_completion_item, #signature_help, #text_documentation
Methods included from Common
#binder, #comments, #name, #namespace, #path, #return_type
Constructor Details
#initialize(method: nil, receiver: nil, name: method&.name, receiver_method_name: name, **splat) ⇒ DelegatedMethod
A DelegatedMethod can be constructed with either a :resolved_method pin, or a :receiver_chain. When a :receiver_chain is supplied, it will be used to dynamically resolve a receiver type within the given closure/scope, and the delegated method will then be resolved to a method pin on that type.
18 19 20 21 22 23 24 25 |
# File 'lib/solargraph/pin/delegated_method.rb', line 18 def initialize(method: nil, receiver: nil, name: method&.name, receiver_method_name: name, **splat) raise ArgumentError, 'either :method or :receiver is required' if (method && receiver) || (!method && !receiver) super(name: name, **splat) @receiver_chain = receiver @resolved_method = method @receiver_method_name = receiver_method_name end |
Instance Method Details
#resolvable?(api_map) ⇒ Boolean
42 43 44 45 |
# File 'lib/solargraph/pin/delegated_method.rb', line 42 def resolvable?(api_map) resolve_method(api_map) !!@resolved_method end |