BlockChain
Makes it easy to chain nested blocks together without creating a ton of nesting.
Installation
Install as usual: gem install block_chain
or add gem 'block_chain'
to your Gemfile.
Usage
Turn this:
foo do
do
baz do
qux do
yield
end
end
end
end
into this:
require 'block_chain'
BlockChain.new(method(:foo), method(:bar), method(:baz), method(:qux)).call { yield }
or:
require 'block_chain'
methods = [:foo, :bar, :baz, :qux].map { |name| method name }
BlockChain.new(*methods).call { yield }
This can make deeply-nested block wrappings a bit more digestable.
Contributing
Contributions are welcome. Please be sure that your pull requests are atomic so they can be considered and accepted separately.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Credits & License
Copyright © 2013 J. Andrew Marshall. License is available in the LICENSE file.