Skip to content

Commit

Permalink
fix reference storage to support new and old class cache api
Browse files Browse the repository at this point in the history
  • Loading branch information
a-pechenyi committed May 23, 2011
1 parent d2b3f49 commit 0fbe4cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
19 changes: 13 additions & 6 deletions lib/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,20 @@ def self.setup
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
Expand All @@ -251,11 +262,7 @@ def self.omniauth_providers

# 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.
Expand Down
6 changes: 1 addition & 5 deletions lib/devise/mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ def modules

# 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
Expand Down

0 comments on commit 0fbe4cb

Please sign in to comment.