class Dry::Types::Constructor::Function::MethodCall
Coercion via a method call on a known object
@api private
Attributes
name[R]
target[R]
Public Class Methods
[](fn, safe)
click to toggle source
@api private
@return [MethodCall]
# File lib/dry/types/constructor/function.rb, line 106 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)
click to toggle source
Choose or build the base class
@return [Function]
# File lib/dry/types/constructor/function.rb, line 33 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
new(fn)
click to toggle source
Calls superclass method
Dry::Types::Constructor::Function::new
# File lib/dry/types/constructor/function.rb, line 113 def initialize(fn) super @target = fn.receiver @name = fn.name end
Public Instance Methods
to_ast()
click to toggle source
# File lib/dry/types/constructor/function.rb, line 119 def to_ast [:method, target, name] end