Module: Sequel::Plugins::Forme::InstanceMethods
- Defined in:
- lib/sequel/plugins/forme.rb
Constant Summary collapse
- MUTEX =
Mutex.new
- FORM_CLASSES =
{::Forme::Form=>Form}
Instance Method Summary collapse
-
#forme_config(form) ⇒ Object
Configure the
formwith support forSequel::Modelspecific code, such as support for nested attributes. -
#forme_form_class(base) ⇒ Object
Return subclass of base form that includes the necessary Sequel form methods.
-
#forme_input(form, field, opts) ⇒ Object
Return
Forme::Inputinstance based on the given arguments. -
#forme_namespace ⇒ Object
Use the underscored model name as the default namespace.
Instance Method Details
#forme_config(form) ⇒ Object
Configure the form with support for Sequel::Model specific code, such as support for nested attributes.
465 466 467 |
# File 'lib/sequel/plugins/forme.rb', line 465 def forme_config(form) form.namespaces << forme_namespace end |
#forme_form_class(base) ⇒ Object
Return subclass of base form that includes the necessary Sequel form methods.
470 471 472 473 474 475 476 477 478 |
# File 'lib/sequel/plugins/forme.rb', line 470 def forme_form_class(base) unless klass = MUTEX.synchronize{FORM_CLASSES[base]} klass = Class.new(base) klass.send(:include, SequelForm) klass.send(:include, ERBSequelForm) if defined?(::Forme::ERB::Form) && base == ::Forme::ERB::Form MUTEX.synchronize{FORM_CLASSES[base] = klass} end klass end |
#forme_input(form, field, opts) ⇒ Object
Return Forme::Input instance based on the given arguments.
481 482 483 |
# File 'lib/sequel/plugins/forme.rb', line 481 def forme_input(form, field, opts) SequelInput.new(self, form, field, opts).input end |
#forme_namespace ⇒ Object
Use the underscored model name as the default namespace.
486 487 488 |
# File 'lib/sequel/plugins/forme.rb', line 486 def forme_namespace model.send(:underscore, model.name) end |