Class: Bricks::BuilderHashSet
- Inherits:
-
Object
- Object
- Bricks::BuilderHashSet
- Defined in:
- lib/bricks.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #builder(klass, &block) ⇒ Object
-
#initialize(&block) ⇒ BuilderHashSet
constructor
A new instance of BuilderHashSet.
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 |