Class: Administrate::Field::I18nEnum
- Inherits:
-
Select
- Object
- Select
- Administrate::Field::I18nEnum
- Defined in:
- lib/administrate/field/i18n_enum.rb
Defined Under Namespace
Classes: Engine
Instance Method Summary collapse
Instance Method Details
#class_name ⇒ Object
18 19 20 |
# File 'lib/administrate/field/i18n_enum.rb', line 18 def class_name .fetch(:class_name, '').camelcase.downcase end |
#enum_options ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/administrate/field/i18n_enum.rb', line 10 def enums = collection.map do |k, v| [translate(class_name, @attribute, k), k] end enums.unshift(['', nil]) if .fetch(:null, false) == true enums end |
#translate(class_name, attribute, value) ⇒ Object
22 23 24 |
# File 'lib/administrate/field/i18n_enum.rb', line 22 def translate(class_name, attribute, value) I18n.t("#{class_name}.#{attribute}.#{value}", scope: .fetch(:scope, nil), default: value) end |