class Matreska::Builder

Attributes

dolls[R]

Public Class Methods

new(core) click to toggle source
# File lib/matreska.rb, line 6
def initialize(core)
  @dolls = []
  @core = core.respond_to?(:call) ? core : ->env{ core }
end

Public Instance Methods

[](env=nil)
Alias for: call
call(env=nil) click to toggle source
# File lib/matreska.rb, line 16
def call(env=nil)
  build.call(env)
end
Also aliased as: []
clear() click to toggle source
# File lib/matreska.rb, line 26
def clear
  @figures.clear
end
set(doll, *args, &blk) click to toggle source
# File lib/matreska.rb, line 11
def set(doll, *args, &blk)
  @dolls << ->core{ doll.new(core, *args, &blk) }
  self
end

Private Instance Methods

build() click to toggle source
# File lib/matreska.rb, line 21
def build
  @dolls.inject(@core) { |core, doll| doll.call(core) }
end