Module: HstoreRadioButtons::FormBuilder

Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/hstore_radio_buttons/helpers/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#hstore_radio_button(method, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hstore_radio_buttons/helpers/form_helper.rb', line 15

def hstore_radio_button(method, options = {})
  options[:separator] = (options[:separator] ? options[:separator] : "<br />")
  methods = HstoreRadioButtons::MethodNamer.new(method)

  button_set = "#{object.class.human_attribute_name(methods.getter)}#{options[:separator]}"

  object.public_send(methods.options).each do |radio_option|
    button_set += @template.hstore_radio_button(@object_name, methods.getter, radio_option, objectify_options(options))
  end
  (:div, button_set.html_safe).html_safe
end

#hstore_radio_buttons(options = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/hstore_radio_buttons/helpers/form_helper.rb', line 27

def hstore_radio_buttons(options = {})
  all_buttons = ""
  object.class.instance_variable_get(:@hstore_button_getters).each do |method|
    all_buttons += hstore_radio_button(method, options)
  end
  all_buttons.html_safe
end