Module: Pageflow::TranslatedAttributes::ClassMethods Private

Defined in:
app/models/concerns/pageflow/translated_attributes.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

rubocop:todo Style/Documentation

Instance Method Summary collapse

Instance Method Details

#translated_attributes(*names) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Declare which attributes can be overridden per locale. Defines a <name>_translations reader and writer for each of them, mapping locales to values.



27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/concerns/pageflow/translated_attributes.rb', line 27

def translated_attributes(*names)
  self.translated_attribute_names = names.map(&:to_s)

  names.each do |name|
    define_method(:"#{name}_translations") { translations_for(name) }

    define_method(:"#{name}_translations=") do |translations|
      assign_translations(name, translations)
    end
  end
end