Method: Puppet::Pops::Functions::Dispatcher#dispatch
- Defined in:
- lib/puppet/pops/functions/dispatcher.rb
#dispatch(instance, calling_scope, args, &block) ⇒ 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.
Dispatches the call to the first found signature (entry with matching type).
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/puppet/pops/functions/dispatcher.rb', line 30 def dispatch(instance, calling_scope, args, &block) found = @dispatchers.find { |d| d.type.callable_with?(args, block) } unless found args_type = Puppet::Pops::Types::TypeCalculator.singleton.infer_set(block_given? ? args + [block] : args) raise ArgumentError, Puppet::Pops::Types::TypeMismatchDescriber.describe_signatures(instance.class.name, signatures, args_type) end if found.argument_mismatch_handler? msg = found.invoke(instance, calling_scope, args) raise ArgumentError, "'#{instance.class.name}' #{msg}" end catch(:next) do found.invoke(instance, calling_scope, args, &block) end end |