module M8a

Constants

VERSION

Public Class Methods

build(core) click to toggle source
# File lib/matreska.rb, line 32
def build(core)
  Builder.new(core)
end
doll(name, *meth, &blk) click to toggle source
# File lib/matreska.rb, line 36
def doll(name, *meth, &blk)
  if blk
    build_doll(name, &blk)
  else
    build_doll(name) do |core|
      core.send(*meth)
    end
  end
end
Also aliased as: figure
figure(name, *meth, &blk)
Alias for: doll

Private Class Methods

build_doll(name, &blk) click to toggle source
# File lib/matreska.rb, line 48
def build_doll(name, &blk)
  klass = Class.new do
    def initialize(core, *args, &blk)
      @core = core
      @args = args
      @blk = blk
    end

    define_method(:call) do |env|
      core = @core.call(env)
      blk.call(core, *@args, &@blk)
    end
    alias :[] :call
  end
  Object.const_set(name.to_s, klass)
end
initialize(core, *args, &blk) click to toggle source
# File lib/matreska.rb, line 50
def initialize(core, *args, &blk)
  @core = core
  @args = args
  @blk = blk
end