lib/type_contracts/annotations.rb
def recombine(*args, **kwargs)
        hash = build_return_hash

        move_named_param_from_kwargs(args, kwargs)

        num_args = args.size
        num_varargs = num_args - @num_params + 1 # irrelevant if there isn't an actual variadic param
        num_varargs_processed = 0

        next_param_index = 0

        num_args.times do |index|
          arg = args[index]
          param = @params_array[next_param_index]
          name, type = *param

          if type == :rest
            # varargs
            hash[name] = [] if hash[name] == NOT_PROVIDED

            if num_varargs_processed < num_varargs
              hash[name] << arg
              num_varargs_processed += 1
            end

            next_param_index += 1 if num_varargs_processed >= num_varargs
          else
            hash[name] = arg
            next_param_index += 1
          end
        end

        if @variadic
          # Really only used if no variadic params are passed
          hash[@variadic] ||= args
        end

        if @kwariatic
          hash[@kwariatic] = kwargs
        end

        hash
      end
# Recombines a splatted args array and kwargs hash into a single hash
# where the keys are the parameter names on the original method
Recombines a splatted args array and kwargs hash into a single hash
where the keys are the parameter names on the original method
Recombines a splatted args array and kwargs hash into a single hash where the keys are the parameter names on the original method
def recombine(*args, **kwargs)
        hash = build_return_hash
        move_named_param_from_kwargs(args, kwargs)
        num_args = args.size
        num_varargs = num_args - @num_params + 1 
        num_varargs_processed = 0
        next_param_index = 0
        num_args.times do |index|
          arg = args[index]
          param = @params_array[next_param_index]
          name, type = *param
          if type == :rest
            hash[name] = [] if hash[name] == NOT_PROVIDED
            if num_varargs_processed < num_varargs
              hash[name] << arg
              num_varargs_processed += 1
            end
            next_param_index += 1 if num_varargs_processed >= num_varargs
          else
            hash[name] = arg
            next_param_index += 1
          end
        end
        if @variadic
          hash[@variadic] ||= args
        end
        if @kwariatic
          hash[@kwariatic] = kwargs
        end
        hash
      end
def recombine ( * args , ** kwargs ) hash = build_return_hash move_named_param_from_kwargs ( args , kwargs ) num_args = args . size num_varargs = num_args - @num_params + 1 num_varargs_processed = 0 next_param_index = 0 num_args . times do | index | arg = args [ index ] param = @params_array [ next_param_index ] name , type = * param if type == :rest hash [ name ] = [ ] if hash [ name ] == NOT_PROVIDED if num_varargs_processed < num_varargs hash [ name ] << arg num_varargs_processed += 1 end next_param_index += 1 if num_varargs_processed >= num_varargs else hash [ name ] = arg next_param_index += 1 end end if @variadic hash [ @variadic ] ||= args end if @kwariatic hash [ @kwariatic ] = kwargs end hash end
Recombines a splatted args array and kwargs hash into a single hash
where the keys are the parameter names on the original method
Recombines a splatted args array and kwargs hash into a single hash where the keys are the parameter names on the original method
# irrelevant if there isn't an actual variadic param # varargs # Really only used if no variadic params are passed
args
kwargs