Skip to content

Instantly share code, notes, and snippets.

View romul's full-sized avatar

Roman Smirnov romul

View GitHub Profile
module MultilingualModule
def self.define_ml_methods_for(attrs)
languages = APP_CONFIG[:languages].split(/\|/)
attrs.each do |method|
define_method('ml_' + method) do |*args|
yml = YAML.load(send("#{method}_ml").to_s)
hash = yml ? yml : {}
languages.each do |lang|
hash[lang.to_sym] = "" unless hash[lang.to_sym]
end