lib/world_flags/util/language.rb in world-flags-0.4.2 vs lib/world_flags/util/language.rb in world-flags-0.4.3
- old
+ new
@@ -1,9 +1,9 @@
module WorldFlags
module Util
module Language
- attr_writer :languages_map
+ attr_writer :languages_map, :hashied_languages
def language_label code, locale
language code, locale
end
@@ -48,13 +48,24 @@
res
end
end
end
+ def hashied_languages
+ @hashied_languages ||= begin
+ case languages
+ when Hash
+ Hashie::Mash.new languages
+ else
+ languages
+ end
+ end
+ end
+
def find_language_map loc
- languages.respond_to?(loc) ? languages.send(loc) : languages.send(locale(loc))
+ hashied_languages.respond_to?(loc) ? hashied_languages.send(loc) : hashied_languages.send(locale(loc))
rescue
- languages.send(default_locale_used)
+ hashied_languages.send(default_locale_used)
end
end
end
end
\ No newline at end of file