Class: ToQuickform::ElementFactory
- Inherits:
-
Object
- Object
- ToQuickform::ElementFactory
- Defined in:
- lib/to_quickform/element_factory.rb
Overview
ElementFactory
Class Method Summary collapse
-
.create_instance(type, options) ⇒ Object
Passes configuration options to instantiated class.
- .new(element) ⇒ Object
Class Method Details
.create_instance(type, options) ⇒ Object
Passes configuration options to instantiated class
23 24 25 26 |
# File 'lib/to_quickform/element_factory.rb', line 23 def self.create_instance(type, ) constant = ToQuickform::Element.const_get ActiveSupport::Inflector.camelize(type) constant.new end |
.new(element) ⇒ Object
17 18 19 20 |
# File 'lib/to_quickform/element_factory.rb', line 17 def self.new(element) return create_instance(element["type"], element) if element raise ArgumentError, 'must provide element to be instantiated' end |