class Beethoven::Composer
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.
Public Class Methods
new(*fs)
click to toggle source
# File lib/beethoven/composer.rb, line 8 def initialize(*fs) @fs = if fs.size == 1 && fs[0].is_a?(Array) fs[0] else fs end end
Public Instance Methods
new(x)
click to toggle source
# File lib/beethoven/composer.rb, line 16 def new(x) @fs.reduce(x) { |a, e| e.new(a) } end