Class: Language

Inherits:
ApplicationRecord
  • Object
show all
Includes:
FlatPriority, RequiredUniqueSlug
Defined in:
app/models/language.rb

Overview

Language

Attributes:

active [Boolean]
code [String]
created_at [DateTime]
object_count [Integer]
priority [Integer]
slug [String]
updated_at [DateTime]

Constant Summary collapse

CODE_PATTERN =
/\A[a-z]{2,3}(-[A-z][a-z]{3})?(-[A-Z]{2})?\z/.freeze
SLUG_PATTERN =
/\A[a-z][-a-z0-9]{,18}[a-z0-9]\z/.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FlatPriority

#change_priority

Class Method Details

.[](code) ⇒ Object

Parameters:

  • code (String|Symbol)


28
29
30
# File 'app/models/language.rb', line 28

def self.[](code)
  find_by(code: code)
end

Instance Method Details

#nameObject



32
33
34
# File 'app/models/language.rb', line 32

def name
  I18n.t("languages.#{slug}", default: slug)
end