Class: Lit::Localization
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Lit::Localization
- Defined in:
- app/models/lit/localization.rb
Instance Method Summary collapse
-
#changed ⇒ Object
SCOPES.
- #full_key ⇒ Object
- #get_value ⇒ Object
- #last_change ⇒ Object
-
#locale ⇒ Object
ASSOCIATIONS.
-
#locale_id ⇒ Object
VALIDATIONS.
- #locale_str ⇒ Object
- #localization_key_str ⇒ Object
- #to_s ⇒ Object
-
#translated_value ⇒ Object
ACCESSIBLE.
-
#translated_value_changed? ⇒ Object
BEFORE & AFTER.
- #update_default_value(value) ⇒ Object
- #value ⇒ Object
Instance Method Details
#changed ⇒ Object
SCOPES
7 |
# File 'app/models/lit/localization.rb', line 7 scope :changed, proc { where(is_changed: true) } |
#full_key ⇒ Object
37 38 39 |
# File 'app/models/lit/localization.rb', line 37 def full_key [locale.locale, localization_key.localization_key].join('.') end |
#get_value ⇒ Object
41 42 43 |
# File 'app/models/lit/localization.rb', line 41 def get_value (is_changed? && (!translated_value.nil?)) ? translated_value : default_value end |
#last_change ⇒ Object
57 58 59 |
# File 'app/models/lit/localization.rb', line 57 def last_change updated_at.to_s(:db) end |
#locale ⇒ Object
ASSOCIATIONS
12 |
# File 'app/models/lit/localization.rb', line 12 belongs_to :locale |
#locale_id ⇒ Object
VALIDATIONS
18 19 |
# File 'app/models/lit/localization.rb', line 18 validates :locale_id, presence: true |
#locale_str ⇒ Object
53 54 55 |
# File 'app/models/lit/localization.rb', line 53 def locale_str locale.locale end |
#localization_key_str ⇒ Object
49 50 51 |
# File 'app/models/lit/localization.rb', line 49 def localization_key_str localization_key.localization_key end |
#to_s ⇒ Object
33 34 35 |
# File 'app/models/lit/localization.rb', line 33 def to_s get_value end |
#translated_value ⇒ Object
ACCESSIBLE
23 |
# File 'app/models/lit/localization.rb', line 23 attr_accessible :translated_value, :locale_id |
#translated_value_changed? ⇒ Object
BEFORE & AFTER
27 28 29 30 |
# File 'app/models/lit/localization.rb', line 27 if: :translated_value_changed? do |o| o.before_update :update_is_changed_attribute o.before_update :create_version end |
#update_default_value(value) ⇒ Object
61 62 63 64 65 |
# File 'app/models/lit/localization.rb', line 61 def update_default_value(value) return true if persisted? && default_value == value self.default_value = value self.save! end |
#value ⇒ Object
45 46 47 |
# File 'app/models/lit/localization.rb', line 45 def value get_value end |