Class: ActionView::Helpers::FormBuilder::PropertySetFormBuilderProxy
- Inherits:
-
Object
- Object
- ActionView::Helpers::FormBuilder::PropertySetFormBuilderProxy
- Defined in:
- lib/property_sets/action_view_extension.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#object_name ⇒ Object
readonly
Returns the value of attribute object_name.
-
#property_set ⇒ Object
readonly
Returns the value of attribute property_set.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #check_box(property, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
- #hidden_field(property, options = {}) ⇒ Object
-
#initialize(property_set, template, object_name, object) ⇒ PropertySetFormBuilderProxy
constructor
A new instance of PropertySetFormBuilderProxy.
- #radio_button(property, checked_value = "1", options = {}) ⇒ Object
- #select(property, choices, options = {}, html_options = {}) ⇒ Object
- #text_field(property, options = {}) ⇒ Object
Constructor Details
#initialize(property_set, template, object_name, object) ⇒ PropertySetFormBuilderProxy
Returns a new instance of PropertySetFormBuilderProxy.
9 10 11 12 13 14 |
# File 'lib/property_sets/action_view_extension.rb', line 9 def initialize(property_set, template, object_name, object) @property_set = property_set @template = template @object_name = object_name @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
7 8 9 |
# File 'lib/property_sets/action_view_extension.rb', line 7 def object @object end |
#object_name ⇒ Object (readonly)
Returns the value of attribute object_name.
7 8 9 |
# File 'lib/property_sets/action_view_extension.rb', line 7 def object_name @object_name end |
#property_set ⇒ Object (readonly)
Returns the value of attribute property_set.
7 8 9 |
# File 'lib/property_sets/action_view_extension.rb', line 7 def property_set @property_set end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
7 8 9 |
# File 'lib/property_sets/action_view_extension.rb', line 7 def template @template end |
Instance Method Details
#check_box(property, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
16 17 18 19 20 21 |
# File 'lib/property_sets/action_view_extension.rb', line 16 def check_box(property, = {}, checked_value = "1", unchecked_value = "0") = (property, ) do |properties| properties.send(:"#{property}?") end template.check_box(object_name, property, , checked_value, unchecked_value) end |
#hidden_field(property, options = {}) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/property_sets/action_view_extension.rb', line 35 def hidden_field(property, = {}) = prepare_id_name(property, ) unless .key?(:value) [:value] = cast_boolean([:object].send(property_set).send(property)) end template.hidden_field(object_name, property, ) end |
#radio_button(property, checked_value = "1", options = {}) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/property_sets/action_view_extension.rb', line 23 def (property, checked_value = "1", = {}) [:id] ||= "#{object_name}_#{property_set}_#{property}_#{checked_value}" = (property, ) do |properties| properties.send(property.to_s) == checked_value end template.(object_name, property, checked_value, ) end |
#select(property, choices, options = {}, html_options = {}) ⇒ Object
43 44 45 46 47 |
# File 'lib/property_sets/action_view_extension.rb', line 43 def select(property, choices, = {}, = {}) = prepare_id_name(property, ) current_value = [:object].send(property_set).send(property) template.select("#{object_name}[#{property_set}]", property, choices, {selected: current_value}, ) end |
#text_field(property, options = {}) ⇒ Object
31 32 33 |
# File 'lib/property_sets/action_view_extension.rb', line 31 def text_field(property, = {}) template.text_field(object_name, property, prepare_id_name(property, )) end |