Class: Dry::Types::Constructor::Function::MethodCall Private
- Inherits:
-
Dry::Types::Constructor::Function
- Object
- Dry::Types::Constructor::Function
- Dry::Types::Constructor::Function::MethodCall
- Defined in:
- lib/dry/types/constructor/function.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Coercion via a method call on a known object
Direct Known Subclasses
Defined Under Namespace
Classes: PrivateCall, PrivateSafeCall, PublicCall
Instance Attribute Summary collapse
- #name ⇒ Object readonly private
- #target ⇒ Object readonly private
Attributes inherited from Dry::Types::Constructor::Function
Class Method Summary collapse
- .[](fn, safe) ⇒ MethodCall private
-
.call_class(method, public, safe) ⇒ Function
private
Choose or build the base class.
Instance Method Summary collapse
-
#initialize(fn) ⇒ MethodCall
constructor
private
A new instance of MethodCall.
- #to_ast ⇒ Object private
Methods inherited from Dry::Types::Constructor::Function
#<<, #>>, #arity, #call, #wrapper?, yields_block?
Constructor Details
#initialize(fn) ⇒ MethodCall
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of MethodCall.
110 111 112 113 114 |
# File 'lib/dry/types/constructor/function.rb', line 110 def initialize(fn) super @target = fn.receiver @name = fn.name end |
Instance Attribute Details
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
108 109 110 |
# File 'lib/dry/types/constructor/function.rb', line 108 def name @name end |
#target ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
108 109 110 |
# File 'lib/dry/types/constructor/function.rb', line 108 def target @target end |
Class Method Details
.[](fn, safe) ⇒ MethodCall
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
103 104 105 106 |
# File 'lib/dry/types/constructor/function.rb', line 103 def self.[](fn, safe) public = fn.receiver.respond_to?(fn.name) MethodCall.call_class(fn.name, public, safe).new(fn) end |
.call_class(method, public, safe) ⇒ Function
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Choose or build the base class
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dry/types/constructor/function.rb', line 32 def self.call_class(method, public, safe) @cache.fetch_or_store([method, public, safe]) do if public ::Class.new(PublicCall) do include PublicCall.call_interface(method, safe) define_method(:__to_s__) do "#<PublicCall for :#{method}>" end end elsif safe PrivateCall else PrivateSafeCall end end end |
Instance Method Details
#to_ast ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
116 |
# File 'lib/dry/types/constructor/function.rb', line 116 def to_ast = [:method, target, name] |