Module: SelectableAttrRails::Helpers::RadioButtonGroupHelper::Base

Defined in:
lib/selectable_attr_rails/helpers/radio_button_group_helper.rb

Instance Method Summary collapse

Instance Method Details

#radio_button_group(object_name, method, options = nil, &block) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/selectable_attr_rails/helpers/radio_button_group_helper.rb', line 35

def radio_button_group(object_name, method, options = nil, &block)
  object = (options || {})[:object] || instance_variable_get("@#{object_name}")
  builder = Builder.new(object, object_name, method, options, self)
  if block_given?
    yield(builder)
    return nil
  else
    result = ''
    builder.each do
      result << builder.radio_button
      result << builder.label
    end
    return result.respond_to?(:html_safe) ? result.html_safe : result
  end
end