Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 36 lines (30 sloc) 0.927 kb
module Draper
module ViewContext
def view_context
super.tap do |context|
Draper::ViewContext.current = context
end
end
def self.current_controller
Thread.current[:current_controller] || ApplicationController.new
end
def self.current_controller=(controller)
Thread.current[:current_controller] = controller
end
def self.current
Thread.current[:current_view_context] ||= build_view_context
end
def self.current=(context)
Thread.current[:current_view_context] = context
end
def self.build_view_context
current_controller.view_context.tap do |context|
if defined?(ActionController::TestRequest)
context.controller.request ||= ActionController::TestRequest.new
context.request ||= context.controller.request
context.params ||= {}
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.