Class: ActionView::Helpers::AttributeBuilders::Button
- Inherits:
-
Object
- Object
- ActionView::Helpers::AttributeBuilders::Button
- Includes:
- Submittable
- Defined in:
- lib/actionview_attribute_builders/attribute_builders/button.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #html_attributes ⇒ Object
-
#initialize(value = nil, options = {}, object, object_name, template_object) ⇒ Button
constructor
A new instance of Button.
Constructor Details
#initialize(value = nil, options = {}, object, object_name, template_object) ⇒ Button
Returns a new instance of Button.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/actionview_attribute_builders/attribute_builders/button.rb', line 12 def initialize(value = nil, = {}, object, object_name, template_object) @object_name = object_name @object = object @template_object = template_object @value = value = case @value when Hash = @value @value = nil when Symbol = { name: @template_object.field_name(@value), id: @template_object.field_id(@value) }.merge!(.to_h) @value = nil end @value ||= submit_default_value formmethod = [:formmethod] if formmethod.present? && !/post|get/i.match?(formmethod) && !.key?(:name) && !.key?(:value) .merge! formmethod: :post, name: "_method", value: formmethod end end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/actionview_attribute_builders/attribute_builders/button.rb', line 10 def value @value end |
Instance Method Details
#html_attributes ⇒ Object
36 37 38 |
# File 'lib/actionview_attribute_builders/attribute_builders/button.rb', line 36 def html_attributes end |