Permalink
Browse files

improve mongoid code as ar was rewritten by @rewritten

  • Loading branch information...
1 parent e987024 commit 184320448cf4f1e217e3217a9a7b815193dc7df7 @nofxx committed Nov 23, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/symbolize/mongoid.rb
@@ -55,7 +55,7 @@ def symbolize *attr_names
enum = configuration[:in] || configuration[:within]
i18n = configuration.delete(:i18n)
- i18n = (!enum.instance_of?(Hash) && enum) if i18n.nil?
+ i18n = (!enum.instance_of?(Hash) && enum) if i18n.nl?
@rewritten
rewritten Nov 23, 2012

Is i18n.nl (instead of .nil) intended? Wouldn't be clearer to use i18n ||= enum if enum.is_a? Hash

scopes = configuration.delete :scopes
methods = configuration.delete :methods
capitalize = configuration.delete :capitalize
@@ -132,7 +132,7 @@ def symbolize *attr_names
define_method "#{attr_name}_text" do
attr = read_attribute(attr_name)
return nil if attr.nil?
- I18n.t("mongoid.symbolizes.#{ActiveSupport::Inflector.underscore(self.class.model_name)}.#{attr_name}.#{attr}")
+ I18n.t("mongoid.symbolizes.#{self.class.model_name.underscore}.#{attr_name}.#{attr}")
end
elsif enum
class_eval("def #{attr_name}_text; #{attr_name.to_s.upcase}_VALUES[#{attr_name}]; end")
@@ -147,4 +147,4 @@ def symbolize *attr_names
end # Symbolize
end # Mongoid
-Symbolize::Mongoid = Mongoid::Symbolize
+# Symbolize::Mongoid = Mongoid::Symbolize

0 comments on commit 1843204

Please sign in to comment.