Class: RailsAdmin::Config::Fields::Types::ActiveRecordEnum

Inherits:
Enum
  • Object
show all
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

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

#inspect

Methods included from Groupable

#group

Methods included from Hideable

#hidden?, #hide, included, #show

Methods included from Configurable

#has_option?, #register_deprecated_instance_option, #register_instance_option

Methods included from Proxyable

#bindings, #bindings=, #with

Constructor Details

This class inherits a constructor from RailsAdmin::Config::Fields::Base

Instance Method Details

#form_valueObject


41
42
43
# File 'lib/rails_admin/config/fields/types/active_record_enum.rb', line 41

def form_value
  enum[super] || super
end

#parse_input(params) ⇒ Object


35
36
37
38
39
# File 'lib/rails_admin/config/fields/types/active_record_enum.rb', line 35

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
# File 'lib/rails_admin/config/fields/types/active_record_enum.rb', line 30

def parse_value(value)
  return unless value.present?
  abstract_model.model.attribute_types[name.to_s].serialize(value)
end

#typeObject


10
11
12
# File 'lib/rails_admin/config/fields/types/active_record_enum.rb', line 10

def type
  :enum
end