Module: Mobility::Backends::ActiveRecord::Table::TranslationsHasManyExtension

Defined in:
lib/mobility/backends/active_record/table.rb

Instance Method Summary collapse

Instance Method Details

#destroy_empty_translations(required_attributes) ⇒ Object

Destroys translations with all empty values


301
302
303
304
# File 'lib/mobility/backends/active_record/table.rb', line 301

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

Parameters:

  • locale (Symbol, String)

295
296
297
298
# File 'lib/mobility/backends/active_record/table.rb', line 295

def in_locale(locale)
  locale = locale.to_s
  find { |t| t.locale == locale }
end