Sha256: 4c421f82f0397de39d10ecbe340daf7634f727d1acd44f2c12942cdec459dbaf

Contents?: true

Size: 685 Bytes

Versions: 51

Compression:

Stored size: 685 Bytes

Contents

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

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

      result = super(*attr_names)

      unless 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

51 entries across 51 versions & 1 rubygems

Version Path
lalala-4.1.0.dev.324 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.322 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.321 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.318 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.316 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.314 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.313 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.309 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.305 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.299 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.291 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.288 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.285 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.284 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.283 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.279 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.277 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.275 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.269 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.267 lib/lalala/ext_active_record/i18n_translations_writer.rb