Sha256: 9f1010af265618efe0e538b090f81763a70b2b06bfbb775cdccafa516831a039
Contents?: true
Size: 657 Bytes
Versions: 1
Compression:
Stored size: 657 Bytes
Contents
module Beethoven # Composer composes class instantiation. The first call to new refers to the # `initialize` method, and creates an object which duck-types Class.new. When # `Composer#new` is called, the classes are instantiated in order, where the # argument passed to the first class is the argument passed to Composer#new, # and each subsequent class receives the instantiated object as its argument. class Composer def initialize(*fs) @fs = if fs.size == 1 && fs[0].is_a?(Array) fs[0] else fs end end def new(x) @fs.reduce(x) { |a, e| e.new(a) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
beethoven-0.1.0 | lib/beethoven/composer.rb |