Sha256: f76fbe3498f1ae6e0191220eee605bb0653e4837067230538e7cb9bf03a2ec6e

Contents?: true

Size: 681 Bytes

Versions: 76

Compression:

Stored size: 681 Bytes

Contents

module Lalala::ExtActiveRecord::I18nTranslationsWriter
  extend ActiveSupport::Concern

  module ClassMethods
    def translates(*attr_names)
      init = translates?

      result = super(*attr_names)

      if init
        include Writer
        attr_accessible :translations_writer
      end

      result
    end
  end

  module Writer
    def translations_writer=(attributes)
      _locale = I18n.locale

      I18n.available_locales.each do |locale|
        I18n.locale = locale
        attrs = attributes[locale.to_s]
        if attrs
          self.assign_attributes(attrs)
        end
      end

      attributes
    ensure
      I18n.locale = _locale
    end
  end

end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
lalala-4.0.0.dev.73 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.72 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.71 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.66 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.65 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.64 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.63 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.62 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.61 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.60 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.59 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.58 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.57 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.56 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.50 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.46 lib/lalala/ext_active_record/i18n_translations_writer.rb