Module: Sequel::Plugins::Forme::InstanceMethods
- Defined in:
- lib/sequel/plugins/forme.rb
Constant Summary collapse
Instance Method Summary collapse
-
#forme_config(form) ⇒ Object
Configure the
form
with support forSequel::Model
specific code, such as support for nested attributes. - #forme_default_request_method ⇒ Object
-
#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::Input
instance 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.
475 476 477 |
# File 'lib/sequel/plugins/forme.rb', line 475 def forme_config(form) form.namespaces << forme_namespace end |
#forme_default_request_method ⇒ Object
495 496 497 |
# File 'lib/sequel/plugins/forme.rb', line 495 def forme_default_request_method 'post' end |
#forme_form_class(base) ⇒ Object
Return subclass of base form that includes the necessary Sequel form methods.
480 481 482 483 484 485 486 487 488 |
# File 'lib/sequel/plugins/forme.rb', line 480 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.
491 492 493 |
# File 'lib/sequel/plugins/forme.rb', line 491 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.
500 501 502 |
# File 'lib/sequel/plugins/forme.rb', line 500 def forme_namespace model.send(:underscore, model.name) end |