Module: HstoreTranslations::Macro

Defined in:
lib/hstore_translations/macro.rb

Instance Method Summary collapse

Instance Method Details

#translates(*attributes) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/hstore_translations/macro.rb', line 4

def translates(*attributes)
  setup_hstore_translations
  self.translatable_attributes |= attributes.map(&:to_sym)

  attributes.each do |attribute|
    define_translations_reader(attribute)
    define_translations_writer(attribute)

    HstoreTranslations.available_locales.each do |locale|
      define_translations_reader(attribute, locale)
      define_translations_writer(attribute, locale)
    end
  end
end