Permalink
Browse files

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.
  • Loading branch information...
1 parent 8781b26 commit ce06b8a56c5647b9b963c2331e3912fbc54e950c @carlosantoniodasilva carlosantoniodasilva committed Aug 11, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 activemodel/lib/active_model/naming.rb
@@ -298,12 +298,15 @@ def self.param_key(record_or_class)
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

2 comments on commit ce06b8a

Owner

rafaelfranca replied Aug 11, 2012

❤️

Owner

rafaelfranca replied Aug 11, 2012

❤️

Please sign in to comment.