Class: Bricks::BuilderHashSet

Inherits:
Object
  • Object
show all
Defined in:
lib/bricks.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ BuilderHashSet

Returns a new instance of BuilderHashSet.



17
18
19
# File 'lib/bricks.rb', line 17

def initialize(&block)
  @builders = {}
end

Instance Method Details

#[](key) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bricks.rb', line 21

def [](key)
  if @builders[key]
    @builders[key]
  elsif Class === key
    @builders[key] = if builder = @builders[key.superclass]
                       builder.derive(:class => key)
                     else
                       builder(key)
                     end
  end
end

#builder(klass, &block) ⇒ Object



33
34
35
# File 'lib/bricks.rb', line 33

def builder(klass, &block)
  @builders[klass] = Bricks::Builder.new(klass, &block)
end