Method: Puppet::Functions::Function3x.from_to_names
- Defined in:
- lib/puppet/functions.rb
.from_to_names(func_info) ⇒ 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.
Compute min and max number of arguments and a list of constructed parameter names p0 - pn (since there are no parameter names in 3x functions).
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 |
# File 'lib/puppet/functions.rb', line 781 def self.from_to_names(func_info) arity = func_info[:arity] if arity.nil? arity = -1 end if arity < 0 from = -arity - 1 # arity -1 is 0 min param, -2 is min 1 param to = :default # infinite range count = -arity # the number of named parameters else count = from = to = arity end # Names of parameters, up to 5 are optimized and use frozen version # Note that (0..count-1) produces expected empty array for count == 0, 0-n for count >= 1 names = count <= 5 ? PARAM_NAMES[count] : (0..count - 1).map { |n| "p#{n}" } [from, to, names] end |