From bb1d3c1f8eae54abae0f97440d6986e25b528b86 Mon Sep 17 00:00:00 2001 From: Pavel Pravosud Date: Sat, 15 Dec 2012 20:57:45 +0700 Subject: AS::BasicObject can be inherited from --- activesupport/lib/active_support/basic_object.rb | 9 +++++++-- activesupport/test/deprecation/basic_object_test.rb | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 activesupport/test/deprecation/basic_object_test.rb diff --git a/activesupport/lib/active_support/basic_object.rb b/activesupport/lib/active_support/basic_object.rb index 242b766b58..d4d06b2aa4 100644 --- a/activesupport/lib/active_support/basic_object.rb +++ b/activesupport/lib/active_support/basic_object.rb @@ -1,7 +1,12 @@ require 'active_support/deprecation' +require 'active_support/proxy_object' module ActiveSupport # :nodoc: - # Deprecated in favor of ActiveSupport::ProxyObject - BasicObject = Deprecation::DeprecatedConstantProxy.new('ActiveSupport::BasicObject', 'ActiveSupport::ProxyObject') + class BasicObject < ProxyObject + def self.inherited(*) + ::ActiveSupport::Deprecation.warn 'ActiveSupport::BasicObject is deprecated! Use ActiveSupport::ProxyObject instead.' + super + end + end end diff --git a/activesupport/test/deprecation/basic_object_test.rb b/activesupport/test/deprecation/basic_object_test.rb new file mode 100644 index 0000000000..4b5bed9eb1 --- /dev/null +++ b/activesupport/test/deprecation/basic_object_test.rb @@ -0,0 +1,12 @@ +require 'abstract_unit' +require 'active_support/deprecation' +require 'active_support/basic_object' + + +class BasicObjectTest < ActiveSupport::TestCase + test 'BasicObject warns about deprecation when inherited from' do + warn = 'ActiveSupport::BasicObject is deprecated! Use ActiveSupport::ProxyObject instead.' + ActiveSupport::Deprecation.expects(:warn).with(warn).once + Class.new(ActiveSupport::BasicObject) + end +end \ No newline at end of file -- cgit v1.2.3