Module: Sequel::Plugins::Localize::ClassMethods

Defined in:
lib/sequel/localize.rb

Instance Method Summary collapse

Instance Method Details

#_init_translationsObject



15
16
17
18
19
20
# File 'lib/sequel/localize.rb', line 15

def _init_translations
  @@_lowercase_name = underscore(demodulize(self.to_s))
  create_translation_class
  create_translated_field_methods
  create_translation_accessors
end

#add_translation_accessors(code) ⇒ Object



27
28
29
30
# File 'lib/sequel/localize.rb', line 27

def add_translation_accessors(code)
  create_translation_writer(code)
  create_translation_reader(code)
end

#localized_fieldsObject



21
22
23
# File 'lib/sequel/localize.rb', line 21

def localized_fields
  @@localized_fields ||= translation_class.columns - [translation_class.primary_key, :"#{@@_lowercase_name}_id", :language_id]
end

#translation_classObject



24
25
26
# File 'lib/sequel/localize.rb', line 24

def translation_class
  @@translation_class ||= Object.const_get("#{self}Translation")
end