Sha256: 1873bd4f05253d46fd20057c28f6f10a4ce18410ea801c04a3fbf60b0ec443b7

Contents?: true

Size: 503 Bytes

Versions: 1

Compression:

Stored size: 503 Bytes

Contents

# frozen_string_literal: true

class LanguageType
  include EnumField::DefineEnum
  attr_reader :code

  def initialize(code)
    @code = code.to_sym
  end

  def title
    I18n.t(code, scope: [:language_type])
  end

  define_enum do |builder|
    builder.member :default, object: new(:default)
    builder.member :top5,    object: new(:top5)
    builder.member :top10,   object: new(:top10)
  end

  all.map(&:code).each do |code|
    define_method "#{code}?" do
      @code == code
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/models/enums/language_type.rb