Sha256: ce0692446c4cc12885b4bda578eb55828fd07d5f2c78cfa4c77e27c6a6387341
Contents?: true
Size: 579 Bytes
Versions: 54
Compression:
Stored size: 579 Bytes
Contents
module Para module AttributeField class EnumField < AttributeField::Base register :enum, self def value_for(instance) if (raw_value = instance.send(name)) && path = enum_path_for(instance, raw_value) translation = ::I18n.t("activerecord.#{ path }", default: '') translation.presence || raw_value end end def field_type :selectize end private def enum_path_for(instance, key) ['enums', instance.model_name.i18n_key, name, key].join('.') end end end end
Version data entries
54 entries across 54 versions & 1 rubygems