Module: Mobility::Backends::ActiveRecord::Table::TranslationsHasManyExtension
- Defined in:
- lib/mobility/backends/active_record/table.rb
Instance Method Summary collapse
-
#destroy_empty_translations(required_attributes) ⇒ Object
Destroys translations with all empty values.
-
#in_locale(locale) ⇒ Object
Returns translation in a given locale, or nil if none exist.
Instance Method Details
#destroy_empty_translations(required_attributes) ⇒ Object
Destroys translations with all empty values
306 307 308 309 |
# File 'lib/mobility/backends/active_record/table.rb', line 306 def destroy_empty_translations(required_attributes) empty_translations = select{ |t| required_attributes.map(&t.method(:send)).none? } destroy(empty_translations) if empty_translations.any? end |
#in_locale(locale) ⇒ Object
Returns translation in a given locale, or nil if none exist
300 301 302 303 |
# File 'lib/mobility/backends/active_record/table.rb', line 300 def in_locale(locale) locale = locale.to_s find { |t| t.locale == locale } end |