Class: Lit::Locale

Inherits:
Base
  • Object
show all
Defined in:
app/models/lit/locale.rb

Instance Attribute Summary

Attributes inherited from Base

#retried_created, #retried_updated

Instance Method Summary collapse

Methods inherited from Base

#mark_for_retry, #rolledback_after_insert?, #rolledback_after_update?

Instance Method Details

#all_localizations_countObject



35
36
37
# File 'app/models/lit/locale.rb', line 35

def all_localizations_count
  localizations.active.count(:id)
end

#changed_localizations_countObject



31
32
33
# File 'app/models/lit/locale.rb', line 31

def changed_localizations_count
  localizations.active.changed.count(:id)
end

#localeObject

VALIDATIONS



11
# File 'app/models/lit/locale.rb', line 11

validates :locale, presence: true, uniqueness: true

#localizationsObject

ASSOCIATIONS



8
# File 'app/models/lit/locale.rb', line 8

has_many :localizations, dependent: :destroy

#orderedObject

SCOPES



4
# File 'app/models/lit/locale.rb', line 4

scope :ordered, -> { order(locale: :asc) }

#to_sObject



22
23
24
# File 'app/models/lit/locale.rb', line 22

def to_s
  locale
end

#translated_percentageObject



26
27
28
29
# File 'app/models/lit/locale.rb', line 26

def translated_percentage
  total = all_localizations_count
  total > 0 ? (changed_localizations_count * 100 / total) : 0
end