Sha256: 0dbf493ad32103b665ac48b641250284ef83528884a50b8ef1c974ee530b39ec
Contents?: true
Size: 711 Bytes
Versions: 3
Compression:
Stored size: 711 Bytes
Contents
module EnumHelp module I18n # overwrite the enum method def enum( definitions ) klass = self super( definitions ) definitions.each do |name, values| # def status_i18n() statuses.key self[:status] end i18n_method_name = "#{name}_i18n".to_sym define_method(i18n_method_name) do enum_value = self.send(name) if enum_value ::I18n.t("enums.#{klass.to_s.underscore}.#{name}.#{enum_value}", default: enum_value) else nil end end end end def self.extended(receiver) # receiver.class_eval do # # alias_method_chain :enum, :enum_help # end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
enum_help-0.0.9 | lib/enum_help/i18n.rb |
enum_help-0.0.8 | lib/enum_help/i18n.rb |
enum_help-0.0.7 | lib/enum_help/i18n.rb |