lib/enum_help/i18n.rb in enum_help-0.0.6 vs lib/enum_help/i18n.rb in enum_help-0.0.7
- old
+ new
@@ -8,10 +8,14 @@
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)
+ if enum_value
+ ::I18n.t("enums.#{klass.to_s.underscore}.#{name}.#{enum_value}", default: enum_value)
+ else
+ nil
+ end
end
end
end