Sha256: b7c9e489ea8e51afa34c76b369cb09468247d08c05d1db8b91fc7c88a60040bb

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 Bytes

Contents

= get_args

Extracted from Merb, get_args allows you to query a method for its argument names and defaults.

This gem exists so you can get this functionality without having to include all of Merb.

== Usage

    class Dummy
      def one_arg(foo); end
      def multiple_args(foo, bar, baz); end
      def optional_args(foo, bar = 1); end
      def star_args(*foo); end
    end

    Dummy.instance_method(:one_arg).get_args
    # => [[[:foo]], []]

    Dummy.instance_method(:multiple_args).get_args
    # => [[[:foo], [:bar], [:baz]], []]

    Dummy.instance_method(:optional_args).get_args
    # => [[[:foo], [:bar, 1]], [:bar]]

    Dummy.instance_method(:star_args).get_args
    # => [[[%s[*foo]]], []]

== Copyright

Copyright (c) 2009 Clinton R. Nixon. See LICENSE for details.

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
get_args-1.1.1 README.rdoc
get_args-1.1.0 README.rdoc
get_args-1.0.0 README.rdoc