Module: EnumHelp::SimpleForm::BuilderExtension
- Defined in:
- lib/enum_help/simple_form.rb
Instance Method Summary collapse
- #default_input_type_with_enum(*args, &block) ⇒ Object
- #is_enum_attributes?(attribute_name) ⇒ Boolean
Instance Method Details
#default_input_type_with_enum(*args, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/enum_help/simple_form.rb', line 7 def default_input_type_with_enum(*args, &block) att_name = (args.first || @attribute_name).to_s = args.last return :enum_radio_buttons if .is_a?(Hash) && [:as] == :radio_buttons && is_enum_attributes?( att_name ) return :enum if (.is_a?(Hash) ? [:as] : @options[:as]).nil? && is_enum_attributes?( att_name ) default_input_type_without_enum(*args, &block) end |
#is_enum_attributes?(attribute_name) ⇒ Boolean
20 21 22 |
# File 'lib/enum_help/simple_form.rb', line 20 def is_enum_attributes?( attribute_name ) object.class.defined_enums.key?(attribute_name) && attribute_name.pluralize != "references" end |