Revert "clean up lazy loading of serialization support for

ActiveRecord::Base and ActionController::Base"

The whole idea of having a lazy hook is that it can be executed
in the context of different targets. The moment you hardcode the class,
the hooks can no longer run in the proper context.

This reverts commit 506e2ac9ad.
This commit is contained in:
José Valim 2012-10-17 19:28:02 +02:00
parent 634f5ba91e
commit be70c5c846
2 changed files with 2 additions and 14 deletions

View File

@ -57,7 +57,7 @@ module ActiveModel::SerializerSupport
end end
ActiveSupport.on_load(:active_record) do ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.send(:include, ActiveModel::SerializerSupport) include ActiveModel::SerializerSupport
end end
module ActiveModel::ArraySerializerSupport module ActiveModel::ArraySerializerSupport
@ -78,7 +78,7 @@ begin
require 'action_controller/serialization' require 'action_controller/serialization'
ActiveSupport.on_load(:action_controller) do ActiveSupport.on_load(:action_controller) do
ActionController::Base.send(:include, ActionController::Serialization) include ::ActionController::Serialization
end end
rescue LoadError => ex rescue LoadError => ex
# rails on installed, continuing # rails on installed, continuing

View File

@ -9,8 +9,6 @@ class RandomModelCollection
end end
module ActiveRecord module ActiveRecord
class Base
end
class Relation class Relation
end end
end end
@ -28,15 +26,5 @@ class SerializerSupportTest < ActiveModel::TestCase
ActiveSupport.run_load_hooks(:active_record) ActiveSupport.run_load_hooks(:active_record)
assert_equal ActiveModel::ArraySerializer, ActiveRecord::Relation.new.active_model_serializer assert_equal ActiveModel::ArraySerializer, ActiveRecord::Relation.new.active_model_serializer
end end
test "it automatically includes serializer support in active_record/base" do
ActiveSupport.run_load_hooks(:active_record)
assert ActiveRecord::Base.new.respond_to?(:active_model_serializer)
end
test "it automatically includes serializer support in action_controller/base" do
ActiveSupport.run_load_hooks(:action_controller)
assert ActionController::Base.new.respond_to?(:serialization_scope)
end
end end