Class: Yoda::Typing::Inferencer::ArgumentsBinder
- Inherits:
-
Object
- Object
- Yoda::Typing::Inferencer::ArgumentsBinder
- Defined in:
- lib/yoda/typing/inferencer/arguments_binder.rb
Instance Attribute Summary collapse
- #generator ⇒ Types::Generator readonly
Instance Method Summary collapse
- #bind(types:, arguments:) ⇒ Hash{ Symbol => Types::Type }
-
#initialize(generator:) ⇒ ArgumentsBinder
constructor
A new instance of ArgumentsBinder.
Constructor Details
#initialize(generator:) ⇒ ArgumentsBinder
Returns a new instance of ArgumentsBinder.
9 10 11 |
# File 'lib/yoda/typing/inferencer/arguments_binder.rb', line 9 def initialize(generator:) @generator = generator end |
Instance Attribute Details
#generator ⇒ Types::Generator (readonly)
6 7 8 |
# File 'lib/yoda/typing/inferencer/arguments_binder.rb', line 6 def generator @generator end |
Instance Method Details
#bind(types:, arguments:) ⇒ Hash{ Symbol => Types::Type }
16 17 18 19 20 |
# File 'lib/yoda/typing/inferencer/arguments_binder.rb', line 16 def bind(types:, arguments:) binds = types.map { |type| ParameterBinder.new(arguments).bind(type: type, generator: generator) } # @todo Select only one signature to bind arguments binds.reduce({}) { |memo, bind| memo.merge!(bind.to_h) { |_key, v1, v2| generator.union_type(v1, v2) } } end |