Class: ActionController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/platanus/gcontroller.rb

Overview

This makes the current request controller globally avaliable.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.currentObject

Gets the current controller.

  • Raises :

    • Platanus::NotInRequestError -> If current controller instance is not avaliable.



23
24
25
# File 'lib/platanus/gcontroller.rb', line 23

def self.current
  Thread.current[:controller] # || (raise Platanus::NotInRequestError, 'Current controller not loaded')
end

Instance Method Details

#wrap_store_controllerObject



11
12
13
14
15
16
17
# File 'lib/platanus/gcontroller.rb', line 11

def wrap_store_controller
  # We could do this instead: http://coderrr.wordpress.com/2008/04/10/lets-stop-polluting-the-threadcurrent-hash/
  Thread.current[:controller] = self
  begin; yield
  ensure; Thread.current[:controller] = nil
  end
end