fix reference storage to support new and old class cache api

This commit is contained in:
Artem Pechenyi 2011-05-23 17:29:10 +03:00
parent d2b3f49384
commit 0fbe4cb6b9
2 changed files with 14 additions and 11 deletions

View File

@ -237,9 +237,20 @@ module Devise
yield self
end
class Getter
def initialize name
@name = name
end
def get
ActiveSupport::Dependencies.constantize(@name)
end
end
def self.ref(arg)
if defined?(ActiveSupport::Dependencies::ClassCache)
ActiveSupport::Dependencies::Reference.store(arg)
ActiveSupport::Dependencies::reference(arg)
Getter.new(arg)
else
ActiveSupport::Dependencies.ref(arg)
end
@ -251,11 +262,7 @@ module Devise
# Get the mailer class from the mailer reference object.
def self.mailer
if defined?(ActiveSupport::Dependencies::ClassCache)
@@mailer_ref.get "Devise::Mailer"
else
@@mailer_ref.get
end
@@mailer_ref.get
end
# Set the mailer reference object to access the mailer.

View File

@ -74,11 +74,7 @@ module Devise
# Gives the class the mapping points to.
def to
if defined?(ActiveSupport::Dependencies::ClassCache)
@ref.get @class_name
else
@ref.get
end
@ref.get
end
def strategies