Sha256: 1363c9cec3e0eb6992e8a8a4fa13efaf6b1d75480cb0dba990dfebd9d9e1fa82
Contents?: true
Size: 446 Bytes
Versions: 20
Compression:
Stored size: 446 Bytes
Contents
class String attr_accessor :origin_model, :origin_name def set_origins obj, name self.origin_model = obj self.origin_name = name self end # forces given locale # I18n.locale = :lv # a = Article.find 18 # a.title # => "LV title" # a.title.in(:en) # => "EN title" def in locale return self unless self.origin_model translation = self.origin_model.in(locale) and translation.send(self.origin_name) end end
Version data entries
20 entries across 20 versions & 1 rubygems