class ToQuickform::ERBFactory
Public Class Methods
new(custom_template)
click to toggle source
# File lib/to_quickform/erb_factory.rb, line 6 def initialize(custom_template) @custom_template = custom_template end
Public Instance Methods
get_default_instance()
click to toggle source
# File lib/to_quickform/erb_factory.rb, line 10 def get_default_instance template = get_default_erb_template(@custom_template, "default") ERB.new(template, nil, '-', '_default') end
get_element_instancue(element)
click to toggle source
# File lib/to_quickform/erb_factory.rb, line 15 def get_element_instancue(element) template = get_element_erb_template(@custom_template, element) ERB.new(template, nil, '-', '_element') end
get_rule_instance(rule)
click to toggle source
# File lib/to_quickform/erb_factory.rb, line 20 def get_rule_instance(rule) template = get_rule_erb_template(@custom_template, rule) ERB.new(template, nil, '-', '_rule') end
Private Instance Methods
get_default_erb_template(custom_template, template)
click to toggle source
# File lib/to_quickform/erb_factory.rb, line 27 def get_default_erb_template(custom_template, template) if custom_template custom_template else case template when "default" ToQuickform::ERBTemplates::BASIC_DEFAULT end end end
get_element_erb_template(custom_template, element)
click to toggle source
# File lib/to_quickform/erb_factory.rb, line 38 def get_element_erb_template(custom_template, element) if custom_template custom_template else case element.type when "checkbox" ToQuickform::ERBTemplates::BASIC_CHECKBOX_ELEMENT_TEMPLATE when "group" ToQuickform::ERBTemplates::BASIC_GROUP_ELEMENT_TEMPLATE when "hidden" ToQuickform::ERBTemplates::BASIC_VALUE_ELEMENT_TEMPLATE when "password" ToQuickform::ERBTemplates::BASIC_ELEMENT_TEMPLATE when "radio" ToQuickform::ERBTemplates::BASIC_RADIO_ELEMENT_TEMPLATE when "reset" ToQuickform::ERBTemplates::BASIC_VALUE_ELEMENT_TEMPLATE when "select" ToQuickform::ERBTemplates::BASIC_SELECT_ELEMENT_TEMPLATE when "text" ToQuickform::ERBTemplates::BASIC_ELEMENT_TEMPLATE when "textarea" ToQuickform::ERBTemplates::BASIC_ELEMENT_TEMPLATE when "submit" ToQuickform::ERBTemplates::BASIC_VALUE_ELEMENT_TEMPLATE end end end
get_rule_erb_template(custom_template, rule)
click to toggle source
# File lib/to_quickform/erb_factory.rb, line 67 def get_rule_erb_template(custom_template, rule) if custom_template custom_template elsif rule.group? ToQuickform::ERBTemplates::BASIC_GROUP_RULE_TEMPLATE else case rule.type when "compare" ToQuickform::ERBTemplates::BASIC_COMPARE_RULE_TEMPLATE when "numeric" ToQuickform::ERBTemplates::BASIC_RULE_TEMPLATE when "regex" ToQuickform::ERBTemplates::BASIC_RULE_TEMPLATE when "required" ToQuickform::ERBTemplates::BASIC_RULE_TEMPLATE end end end