module Enumerize::Hooks::SimpleFormBuilderExtension

Public Instance Methods

input_field_with_enumerize(attribute_name, options={}) click to toggle source
# File lib/enumerize/hooks/simple_form.rb, line 18
def input_field_with_enumerize(attribute_name, options={})
  add_input_options_for_enumerized_attribute(attribute_name, options)
  input_field_without_enumerize(attribute_name, options)
end
input_with_enumerize(attribute_name, options={}, &block) click to toggle source
# File lib/enumerize/hooks/simple_form.rb, line 13
def input_with_enumerize(attribute_name, options={}, &block)
  add_input_options_for_enumerized_attribute(attribute_name, options)
  input_without_enumerize(attribute_name, options, &block)
end

Private Instance Methods

add_input_options_for_enumerized_attribute(attribute_name, options) click to toggle source
# File lib/enumerize/hooks/simple_form.rb, line 25
def add_input_options_for_enumerized_attribute(attribute_name, options)
  klass = object.class

  if klass.respond_to?(:enumerized_attributes) && (attr = klass.enumerized_attributes[attribute_name])
    options[:collection] ||= attr.options

    if attr.kind_of?(Enumerize::Multiple) && options[:as] != :check_boxes
      options[:input_html] = options.fetch(:input_html, {}).merge(:multiple => true)
    end
  end
end