Class: RailsAdmin::Config::Fields::Types::ActiveRecordEnum
- Defined in:
- lib/rails_admin/config/fields/types/active_record_enum.rb
Constant Summary
Constants inherited from Base
Base::NAMED_INSTANCE_VARIABLES
Instance Attribute Summary
Attributes inherited from Base
#abstract_model, #defined, #name, #order, #parent, #properties, #root, #section
Attributes included from Proxyable
Instance Method Summary collapse
Methods inherited from Base
#association?, #editable?, #errors, #form_default_value, #generic_field_help, #generic_help, #initialize, #inverse_of, #method_name, #optional, #optional=, #optional?, #type_css_class, #value, #virtual?
Methods included from Inspectable
Methods included from Groupable
Methods included from Hideable
#hidden?, #hide, included, #show
Methods included from Configurable
#has_option?, included, #register_deprecated_instance_option, #register_instance_option
Methods included from Proxyable
Constructor Details
This class inherits a constructor from RailsAdmin::Config::Fields::Base
Instance Method Details
#form_value ⇒ Object
49 50 51 |
# File 'lib/rails_admin/config/fields/types/active_record_enum.rb', line 49 def form_value enum[super] || super end |
#parse_input(params) ⇒ Object
43 44 45 46 47 |
# File 'lib/rails_admin/config/fields/types/active_record_enum.rb', line 43 def parse_input(params) value = params[name] return unless value params[name] = parse_input_value(value) end |
#parse_value(value) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rails_admin/config/fields/types/active_record_enum.rb', line 30 def parse_value(value) return unless value.present? if ::Rails.version >= '5' abstract_model.model.attribute_types[name.to_s].serialize(value) else # Depending on the colum type and AR version, we might get a # string or an integer, so we need to handle both cases. enum.fetch(value) do type_cast_value(value) end end end |
#type ⇒ Object
10 11 12 |
# File 'lib/rails_admin/config/fields/types/active_record_enum.rb', line 10 def type :enum end |