diff options
author | José Valim <jose.valim@gmail.com> | 2011-11-23 23:45:27 +0000 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-11-23 23:45:27 +0000 |
commit | 7fcc8c0a1f38c77b12cb6ffe81fb2887e6c60b85 (patch) | |
tree | ac081db672326a11910e9c46d93c9675c83c2e87 /activemodel/lib/active_model/serializable.rb | |
parent | 6da52c617e2a075b9d9e7142786f316d8f2c7930 (diff) | |
download | rails-7fcc8c0a1f38c77b12cb6ffe81fb2887e6c60b85.tar.gz rails-7fcc8c0a1f38c77b12cb6ffe81fb2887e6c60b85.tar.bz2 rails-7fcc8c0a1f38c77b12cb6ffe81fb2887e6c60b85.zip |
Rely solely on active_model_serializer and remove the fancy constant lookup.
Diffstat (limited to 'activemodel/lib/active_model/serializable.rb')
-rw-r--r-- | activemodel/lib/active_model/serializable.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/activemodel/lib/active_model/serializable.rb b/activemodel/lib/active_model/serializable.rb index 769e934dbe..70e27c5683 100644 --- a/activemodel/lib/active_model/serializable.rb +++ b/activemodel/lib/active_model/serializable.rb @@ -1,6 +1,7 @@ require 'active_support/core_ext/hash/except' require 'active_support/core_ext/hash/slice' require 'active_support/core_ext/array/wrap' +require 'active_support/core_ext/string/inflections' module ActiveModel # == Active Model Serializable @@ -72,11 +73,10 @@ module ActiveModel autoload :JSON, "active_model/serializable/json" autoload :XML, "active_model/serializable/xml" - include ActiveModel::Serializer::Scope - module ClassMethods #:nodoc: - def _model_serializer - @_model_serializer ||= ActiveModel::Serializer::Finder.find(self, self) + def active_model_serializer + return @active_model_serializer if defined?(@active_model_serializer) + @active_model_serializer = "#{self.name}Serializer".safe_constantize end end @@ -108,8 +108,8 @@ module ActiveModel end # Returns a model serializer for this object considering its namespace. - def model_serializer - self.class._model_serializer + def active_model_serializer + self.class.active_model_serializer end private |