Module: Dina::MultiLingualDescription

Defined in:
lib/dina/utils/multi_lingual_description.rb

Instance Method Summary collapse

Instance Method Details

#set_multilingualDescription(opts = {}) ⇒ Object

Adds or updates a multilingualDescription with a language key

Parameters:

  • opts (Hash) (defaults to: {})

    the description expessed as { en: “My description” }



7
8
9
10
11
12
13
14
15
# File 'lib/dina/utils/multi_lingual_description.rb', line 7

def set_multilingualDescription(opts = {})
  if self.multilingualDescription.nil?
    self.multilingualDescription = opts
  else
    descriptions = multilingualDescription["descriptions"]
    descriptions.delete_if{|o| o["lang"] == opts.keys[0].to_s}
    descriptions << { "lang" => opts.keys[0].to_s, "desc" => opts[opts.keys[0]] }
  end
end