Class: BlockChain
- Inherits:
-
Object
- Object
- BlockChain
- Defined in:
- lib/block_chain.rb,
lib/block_chain/version.rb
Constant Summary collapse
- VERSION =
'0.2.0'
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(*methods) ⇒ BlockChain
constructor
A new instance of BlockChain.
Constructor Details
#initialize(*methods) ⇒ BlockChain
Returns a new instance of BlockChain.
4 5 6 |
# File 'lib/block_chain.rb', line 4 def initialize *methods @procs = methods.map(&:to_proc) end |
Instance Method Details
#call(*args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/block_chain.rb', line 8 def call *args if @procs.none? yield elsif @procs.one? @procs.first.call(*args) { yield } else current = @procs.first nexts = self.class.new(*@procs.slice(1..-1)) current.call(*args) do nexts.call(*args) { yield } end end end |