Module: EnumHelp::I18n
- Defined in:
- lib/enum_help/i18n.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#enum(definitions) ⇒ Object
overwrite the enum method.
Class Method Details
.extended(receiver) ⇒ Object
19 20 21 22 23 |
# File 'lib/enum_help/i18n.rb', line 19 def self.extended(receiver) # receiver.class_eval do # # alias_method_chain :enum, :enum_help # end end |
Instance Method Details
#enum(definitions) ⇒ Object
overwrite the enum method
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/enum_help/i18n.rb', line 5 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) ::I18n.t("enums.#{klass.to_s.underscore}.#{name}.#{enum_value}", default: enum_value) end end end |