Permalink
Browse files

Integrate RequestStore.

Fixes #390
  • Loading branch information...
1 parent ee2a015 commit fde1cde9adfb856750c1f616d8b62d221ef97fc6 @steveklabnik steveklabnik committed Dec 17, 2012
Showing with 7 additions and 4 deletions.
  1. +1 −0 draper.gemspec
  2. +6 −4 lib/draper/view_context.rb
View
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
s.add_dependency 'activesupport', '>= 3.0'
s.add_dependency 'actionpack', '>= 3.0'
+ s.add_dependency 'request_store', '~> 1.0.0'
s.add_development_dependency 'ammeter'
s.add_development_dependency 'rake', '~> 0.9.2'
View
@@ -1,3 +1,5 @@
+require 'request_store'
+
module Draper
module ViewContext
def view_context
@@ -7,19 +9,19 @@ def view_context
end
def self.current_controller
- Thread.current[:current_controller] || ApplicationController.new
+ RequestStore.store[:current_controller] || ApplicationController.new
end
def self.current_controller=(controller)
- Thread.current[:current_controller] = controller
+ RequestStore.store[:current_controller] = controller
end
def self.current
- Thread.current[:current_view_context] ||= build_view_context
+ RequestStore.store[:current_view_context] ||= build_view_context
end
def self.current=(context)
- Thread.current[:current_view_context] = context
+ RequestStore.store[:current_view_context] = context
end
def self.build_view_context

0 comments on commit fde1cde

Please sign in to comment.