lib/roda.rb
# Return the number of required argument, optional arguments,
# whether the callable accepts any additional arguments,
# and whether the callable accepts keyword arguments (true, false
# or :required).
Return the number of required argument, optional arguments,
whether the callable accepts any additional arguments,
and whether the callable accepts keyword arguments (true, false
or :required).
Return the number of required argument optional arguments whether the callable accepts any additional arguments and whether the callable accepts keyword arguments ( true false or : required ) .
def _define_roda_method_arg_numbers(callable)
          optional_args = 0
          rest = false
          keyword = false
          callable.parameters.map(&:first).each do |arg_type, _|
            case arg_type
            when :opt
              optional_args += 1
            when :rest
              rest = true
            when :keyreq
              keyword = :required
            when :key, :keyrest
              keyword ||= true
            end
          end
          arity = callable.arity
          if arity < 0
            arity = arity.abs - 1
          end
          required_args = arity
          arity -= 1 if keyword == :required
          if callable.is_a?(Proc) && !callable.lambda?
            optional_args -= arity
          end
          [required_args, optional_args, rest, keyword]
        end
def _define_roda_method_arg_numbers ( callable ) optional_args = 0 rest = false keyword = false callable . parameters . map ( & :first ) . each do | arg_type , _ | case arg_type when :opt optional_args += 1 when :rest rest = true when :keyreq keyword = :required when :key , :keyrest keyword ||= true end end arity = callable . arity if arity < 0 arity = arity . abs - 1 end required_args = arity arity -= 1 if keyword == :required if callable . is_a? ( Proc ) && ! callable . lambda? optional_args -= arity end [ required_args , optional_args , rest , keyword ] end
Return the number of required argument, optional arguments,
whether the callable accepts any additional arguments,
and whether the callable accepts keyword arguments (true, false
or :required).
Return the number of required argument optional arguments whether the callable accepts any additional arguments and whether the callable accepts keyword arguments ( true false or : required ) .
callable