Move *Builder classes outside AVExtensions::Builder module
Avoid including these classes on FormBuilder.
This commit is contained in:
parent
e9bb32838b
commit
52eec1136d
|
@ -1,9 +1,8 @@
|
||||||
module SimpleForm
|
module SimpleForm
|
||||||
module ActionViewExtensions
|
module ActionViewExtensions
|
||||||
# A collection of methods required by simple_form but added to rails default form.
|
# Base builder to handle each instance of a collection of radio buttons / check boxes.
|
||||||
# This means that you can use such methods outside simple_form context.
|
# Based on (at this time upcoming) Rails 4 collection builders.
|
||||||
module Builder
|
class BuilderBase #:nodoc:
|
||||||
class Builder
|
|
||||||
attr_reader :object, :text, :value
|
attr_reader :object, :text, :value
|
||||||
|
|
||||||
def initialize(template_object, object_name, method_name, object,
|
def initialize(template_object, object_name, method_name, object,
|
||||||
|
@ -23,20 +22,25 @@ module SimpleForm
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class RadioButtonBuilder < Builder
|
# Handles generating an instance of radio + label for collection_radio_buttons.
|
||||||
|
class RadioButtonBuilder < BuilderBase #:nodoc:
|
||||||
def radio_button(extra_html_options={})
|
def radio_button(extra_html_options={})
|
||||||
html_options = extra_html_options.merge(@input_html_options)
|
html_options = extra_html_options.merge(@input_html_options)
|
||||||
@template_object.radio_button(@object_name, @method_name, @value, html_options)
|
@template_object.radio_button(@object_name, @method_name, @value, html_options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class CheckBoxBuilder < Builder
|
# Handles generating an instance of check box + label for collection_check_boxes.
|
||||||
|
class CheckBoxBuilder < BuilderBase #:nodoc:
|
||||||
def check_box(extra_html_options={})
|
def check_box(extra_html_options={})
|
||||||
html_options = extra_html_options.merge(@input_html_options)
|
html_options = extra_html_options.merge(@input_html_options)
|
||||||
@template_object.check_box(@object_name, @method_name, html_options, @value, nil)
|
@template_object.check_box(@object_name, @method_name, html_options, @value, nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# A collection of methods required by simple_form but added to rails default form.
|
||||||
|
# This means that you can use such methods outside simple_form context.
|
||||||
|
module Builder
|
||||||
# Create a collection of radio inputs for the attribute. Basically this
|
# Create a collection of radio inputs for the attribute. Basically this
|
||||||
# helper will create a radio input associated with a label for each
|
# helper will create a radio input associated with a label for each
|
||||||
# text/value option in the collection, using value_method and text_method
|
# text/value option in the collection, using value_method and text_method
|
||||||
|
|
Loading…
Reference in New Issue