Sha256: a3c27e1401847bd3ac1d882a27fe5371901cf19907958aef21c89fb8b5a7e7f0

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

# frozen_string_literal: true

class CategoryType
  include EnumField::DefineEnum

  attr_reader :code, :attachment_type

  def initialize(code, attachment_type = :any)
    @code = code.to_sym
    @attachment_type = attachment_type
  end

  def title
    I18n.t(name, scope: [:category_type])
  end

  define_enum do |builder|
    builder.member :default,     object: new(:default)
    builder.member :website,     object: new(:website, :link)
    builder.member :application, object: new(:application)
    builder.member :software,    object: new(:software)
    builder.member :gaming,      object: new(:gaming)
  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/category_type.rb