Class: FiForm::Configuration
- Inherits:
-
Object
- Object
- FiForm::Configuration
- Defined in:
- lib/fi_form/configuration.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#renderers ⇒ Object
Returns the value of attribute renderers.
Instance Method Summary collapse
-
#add_builder_method(name, &block) ⇒ Object
add custom behaviour.
-
#get_renderer(identifier = nil) ⇒ Object
fetch a renderer.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#register(options) ⇒ Object
Register a renderer.
-
#reload! ⇒ Object
reload renderer classes in development.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 |
# File 'lib/fi_form/configuration.rb', line 14 def initialize @renderers = {} end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
12 13 14 |
# File 'lib/fi_form/configuration.rb', line 12 def default @default end |
#renderers ⇒ Object
Returns the value of attribute renderers.
12 13 14 |
# File 'lib/fi_form/configuration.rb', line 12 def renderers @renderers end |
Instance Method Details
#add_builder_method(name, &block) ⇒ Object
add custom behaviour
24 25 26 |
# File 'lib/fi_form/configuration.rb', line 24 def add_builder_method(name, &block) FiForm::Builder.add_builder_method name, &block end |
#get_renderer(identifier = nil) ⇒ Object
fetch a renderer. if none is specified, the default or debug renderer will be returned
29 30 31 32 |
# File 'lib/fi_form/configuration.rb', line 29 def get_renderer(identifier=nil) identifier ||= default_renderer self.renderers[identifier] || DebugRenderer end |
#register(options) ⇒ Object
Register a renderer. The last added renderer will be the default if not specified
19 20 21 |
# File 'lib/fi_form/configuration.rb', line 19 def register() self.renderers.merge! end |
#reload! ⇒ Object
reload renderer classes in development
35 36 37 |
# File 'lib/fi_form/configuration.rb', line 35 def reload! self.renderers = self.renderers.map{|k, klass| [k, klass.to_s.constantize] }.to_h # uncovered end |