aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-08-11 13:33:27 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-08-11 13:33:28 -0300
commitce06b8a56c5647b9b963c2331e3912fbc54e950c (patch)
treec8b31005cdb957c7100557133de8ce0028b9d65b /activemodel
parent8781b266b92785716dba37665dbe7a4700fa3018 (diff)
downloadrails-ce06b8a56c5647b9b963c2331e3912fbc54e950c.tar.gz
rails-ce06b8a56c5647b9b963c2331e3912fbc54e950c.tar.bz2
rails-ce06b8a56c5647b9b963c2331e3912fbc54e950c.zip
Refactor model name logic and make it a real private class method
Under a "private" call, class methods are not real private methods, they're public just like any other method. Make model_name_from_record_or_class a private class method, and nodoc it.
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/naming.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb
index 2102282c02..c0d93e5d53 100644
--- a/activemodel/lib/active_model/naming.rb
+++ b/activemodel/lib/active_model/naming.rb
@@ -298,12 +298,15 @@ module ActiveModel
model_name_from_record_or_class(record_or_class).param_key
end
- private
- def self.model_name_from_record_or_class(record_or_class)
- return record_or_class.model_name if record_or_class.respond_to?(:model_name)
- return record_or_class.to_model.class.model_name if record_or_class.respond_to?(:to_model)
+ def self.model_name_from_record_or_class(record_or_class) #:nodoc:
+ if record_or_class.respond_to?(:model_name)
+ record_or_class.model_name
+ elsif record_or_class.respond_to?(:to_model)
+ record_or_class.to_model.class.model_name
+ else
record_or_class.class.model_name
end
+ end
+ private_class_method :model_name_from_record_or_class
end
-
end