Sha256: dfd2038b202c34d709654243861a1b53da778d76e37f44a1c172419fbe6da3ca

Contents?: true

Size: 384 Bytes

Versions: 1

Compression:

Stored size: 384 Bytes

Contents

require 'block_chain/version'

class BlockChain
  def initialize *methods
    @procs = methods.map(&:to_proc)
  end

  def call
    if @procs.none?
      yield
    elsif @procs.one?
      @procs.first.call { yield }
    else
      current = @procs.first
      nexts = self.class.new(*@procs.slice(1..-1))
      current.call do
        nexts.call { yield }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
block_chain-0.1.0 lib/block_chain.rb