Rename Kernel#memoize to Kernel#expirable_memoize so that it doesn't conflict with memoize method in ActiveSupport which has an entirely different API and semantics. Reported by [Florian Dütsc (mail@florian-duetsch.de)].

This commit is contained in:
Marcel Molina 2009-04-19 17:01:15 -07:00
Родитель 3f148e1a73
Коммит af27b54b69
5 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -528,7 +528,7 @@ module AWS
# bucket.acl(bucket.acl)
def acl(reload = false)
policy = reload.is_a?(ACL::Policy) ? reload : nil
memoize(reload) do
expirable_memoize(reload) do
self.class.acl(name, policy) if policy
self.class.acl(name)
end
@ -579,7 +579,7 @@ module AWS
# object.acl(object.acl)
def acl(reload = false)
policy = reload.is_a?(ACL::Policy) ? reload : nil
memoize(reload) do
expirable_memoize(reload) do
self.class.acl(key, bucket.name, policy) if policy
self.class.acl(key, bucket.name)
end

Просмотреть файл

@ -133,7 +133,7 @@ module Kernel
caller[1][/`([^']+)'/, 1]
end if RUBY_VERSION > '1.8.7'
def memoize(reload = false, storage = nil)
def expirable_memoize(reload = false, storage = nil)
current_method = RUBY_VERSION >= '1.8.7' ? __called_from__ : __method__(1)
storage = "@#{storage || current_method}"
if reload
@ -174,7 +174,7 @@ class Module
alias_method original_method, method_name
module_eval(<<-EVAL, __FILE__, __LINE__)
def #{method_name}(reload = false, *args, &block)
memoize(reload) do
expirable_memoize(reload) do
send(:#{original_method}, *args, &block)
end
end

Просмотреть файл

@ -485,7 +485,7 @@ module AWS
reload = options
options = {}
end
memoize(reload) do
expirable_memoize(reload) do
self.class.stream(key, bucket.name, options, &block)
end
end
@ -561,7 +561,7 @@ module AWS
def etag(reload = false)
return nil unless stored?
memoize(reload) do
expirable_memoize(reload) do
reload ? about(reload)['etag'][1...-1] : attributes['e_tag'][1...-1]
end
end

Просмотреть файл

@ -4,7 +4,7 @@ module AWS
MAJOR = '0'
MINOR = '6'
TINY = '0'
BETA = nil # Time.now.to_i.to_s
BETA = Time.now.to_i.to_s
end
Version = [VERSION::MAJOR, VERSION::MINOR, VERSION::TINY, VERSION::BETA].compact * '.'

Просмотреть файл

@ -144,13 +144,13 @@ end if RUBY_VERSION < '1.8.7'
class ModuleExtensionsTest < Test::Unit::TestCase
class Foo
def foo(reload = false)
memoize(reload) do
expirable_memoize(reload) do
Time.now
end
end
def bar(reload = false)
memoize(reload, :baz) do
expirable_memoize(reload, :baz) do
Time.now
end
end