Module: Translator::ClassMethods

Defined in:
lib/translator/translator.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) translate_field(name)

Define the mongoId field for translations of field `name`

Parameters:

  • name (String)

    The fieldname which should have translations



13
14
15
16
17
# File 'lib/translator/translator.rb', line 13

def translate_field(name)
  class_eval <<-EOV
    field "#{name}_translations".to_sym, :type => Hash, :default => {}
  EOV
end

- (Object) translate_fields(names)

Define the mongoId field for translations of fields in `names`

Parameters:

  • names (Array)

    An array of fieldnames which should have translations



21
22
23
24
25
# File 'lib/translator/translator.rb', line 21

def translate_fields(names)
  names.each do |name|
    translate_field(name)
  end
end