Module: WhirledPeas::Component::Factory

Defined in:
lib/whirled_peas/component.rb

Class Method Summary collapse

Class Method Details

.build(name) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/whirled_peas/component.rb', line 9

def build(name)
  unless classes.key?(name)
    expected = classes.keys.join(', ')
    raise ArgumentError, "Unrecognized component: #{name.inspect}, expecting one of #{expected}"
  end
  @classes[name].new
end

.register(name, klass) ⇒ Object



5
6
7
# File 'lib/whirled_peas/component.rb', line 5

def register(name, klass)
  classes[name] = klass
end