BlockChain

Build Status

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
  bar 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.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Credits & License

Copyright © 2013 J. Andrew Marshall. License is available in the LICENSE file.