Project

arity

0.0
No commit activity in last 3 years
No release in over 3 years
logic to determine when Ruby functions can be called
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.10
~> 10.0
~> 3.0
 Project Readme

Arity

Logic to determine when Ruby functions can be called.

Installation

Add gem 'arity' to your Gemfile.

Usage

function = Arity::Function.make(some_callable)
# note the use of .make versus .new
# some_callable should respond to :call
# otherwise, .make will raise an Arity::NotCallableError
# to avoid raising, pass {silent: true} to .make and it will return nil instead
function.arity
# delegates to Ruby's built-in arity logic
function.takes?(arg_count: 3, keywords: [:things])
# determines if the supplied method parameter structure is valid.
function.runnable?('thing-1','thing-2','thing-3', things: 3)
# computes the parameter structure and delegates to .takes?
function.run('thing-1','thing-2','thing-3', things: 3)
# calls .call on the callable with the supplied parameters

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fledman/arity.

License

The gem is available as open source under the terms of the MIT License.