aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/lib/active_support/memoizable.rb7
-rw-r--r--activesupport/test/flush_cache_on_private_memoization_test.rb4
-rw-r--r--activesupport/test/memoizable_test.rb24
3 files changed, 28 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/memoizable.rb b/activesupport/lib/active_support/memoizable.rb
index 279f1cf71f..363d799587 100644
--- a/activesupport/lib/active_support/memoizable.rb
+++ b/activesupport/lib/active_support/memoizable.rb
@@ -1,8 +1,15 @@
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/module/aliasing'
+require 'active_support/deprecation'
module ActiveSupport
module Memoizable
+ def self.extended(base)
+ ActiveSupport::Deprecation.warn "ActiveSupport::Memoizable is deprecated and will be removed in future releases," \
+ "simply use Ruby instead.", caller
+ super
+ end
+
def self.memoized_ivar_for(symbol)
"@_memoized_#{symbol.to_s.sub(/\?\Z/, '_query').sub(/!\Z/, '_bang')}".to_sym
end
diff --git a/activesupport/test/flush_cache_on_private_memoization_test.rb b/activesupport/test/flush_cache_on_private_memoization_test.rb
index a7db96eb71..20768b777a 100644
--- a/activesupport/test/flush_cache_on_private_memoization_test.rb
+++ b/activesupport/test/flush_cache_on_private_memoization_test.rb
@@ -2,7 +2,9 @@ require 'abstract_unit'
require 'test/unit'
class FlashCacheOnPrivateMemoizationTest < Test::Unit::TestCase
- extend ActiveSupport::Memoizable
+ ActiveSupport::Deprecation.silence do
+ extend ActiveSupport::Memoizable
+ end
def test_public
assert_method_unmemoizable :pub
diff --git a/activesupport/test/memoizable_test.rb b/activesupport/test/memoizable_test.rb
index 7ffe132b80..e333b9a78c 100644
--- a/activesupport/test/memoizable_test.rb
+++ b/activesupport/test/memoizable_test.rb
@@ -2,7 +2,9 @@ require 'abstract_unit'
class MemoizableTest < ActiveSupport::TestCase
class Person
- extend ActiveSupport::Memoizable
+ ActiveSupport::Deprecation.silence do
+ extend ActiveSupport::Memoizable
+ end
attr_reader :name_calls, :age_calls, :is_developer_calls, :name_query_calls
@@ -65,7 +67,9 @@ class MemoizableTest < ActiveSupport::TestCase
end
module Rates
- extend ActiveSupport::Memoizable
+ ActiveSupport::Deprecation.silence do
+ extend ActiveSupport::Memoizable
+ end
attr_reader :sales_tax_calls
def sales_tax(price)
@@ -77,7 +81,9 @@ class MemoizableTest < ActiveSupport::TestCase
end
class Calculator
- extend ActiveSupport::Memoizable
+ ActiveSupport::Deprecation.silence do
+ extend ActiveSupport::Memoizable
+ end
include Rates
attr_reader :fib_calls
@@ -215,7 +221,9 @@ class MemoizableTest < ActiveSupport::TestCase
def test_object_memoization
[Company.new, Company.new, Company.new].each do |company|
- company.extend ActiveSupport::Memoizable
+ ActiveSupport::Deprecation.silence do
+ company.extend ActiveSupport::Memoizable
+ end
company.memoize :name
assert_equal "37signals", company.name
@@ -249,11 +257,15 @@ class MemoizableTest < ActiveSupport::TestCase
def test_double_memoization
assert_raise(RuntimeError) { Person.memoize :name }
person = Person.new
- person.extend ActiveSupport::Memoizable
+ ActiveSupport::Deprecation.silence do
+ person.extend ActiveSupport::Memoizable
+ end
assert_raise(RuntimeError) { person.memoize :name }
company = Company.new
- company.extend ActiveSupport::Memoizable
+ ActiveSupport::Deprecation.silence do
+ company.extend ActiveSupport::Memoizable
+ end
company.memoize :name
assert_raise(RuntimeError) { company.memoize :name }
end