Sha256: 96b2803bc173ef629641be334742b5de6aedcdeddf2822890a2d1c4f1c1f8d02
Contents?: true
Size: 681 Bytes
Versions: 7
Compression:
Stored size: 681 Bytes
Contents
module AbAdmin module Models class TypeModel include ::EnumField::DefineEnum attr_reader :code class_attribute :codes, :i18n_scope, :instance_writer => false self.codes = [] self.i18n_scope = [:admin, :type_model] def initialize(code) @code = code.to_sym end def self.define_enum_by_codes define_enum do |builder| codes.each do |kind| builder.member kind, :object => new(kind.to_s) end end end def title I18n.t(@code, :scope => i18n_scope) end def self.legal?(value) all.map(&:id).include?(value) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems