Sha256: c7696570927306b62293e5ae5bd5381e92d334cad81d0c5579a024df3c18956e
Contents?: true
Size: 879 Bytes
Versions: 1
Compression:
Stored size: 879 Bytes
Contents
module LostInTranslations module Ruby module ClassMethods def translate(*fields) fields.each do |field| alias_method Ruby.original_field_name(field), field.to_sym end LostInTranslations.define_translation_methods(self, *fields) end end def self.included(base_class) base_class.include Base base_class.extend ClassMethods end def translate(field, locale = I18n.locale) LostInTranslations.translate(self, field, locale) || Ruby.call_original_field(self, field) end def self.call_original_field(object, field) method_name = Ruby.original_field_name(field) return object.send(field) unless object.respond_to?(method_name) object.send(method_name) end def self.original_field_name(field) "original_field_#{field}".to_sym end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lost_in_translations-1.2.0 | lib/lost_in_translations/ruby.rb |