Class: Nitro::Controller

Inherits:
Object
  • Object
show all
Includes:
Caching, Helpers, Publishable, Scaffolding
Defined in:
lib/nitro/controller.rb,
lib/nitro/scaffold/controller.rb

Overview

The Controller part in the MVC paradigm. The controller’s published methods are called actrions. The controller class contains the Publishable mixin and additional helper mixins.

Direct Known Subclasses

AdminController, Service, OgAdminController

Class Method Summary collapse

Methods included from Helpers

append_features

Methods included from Caching

included

Methods included from Scaffolding

class_to_list, class_to_method, class_to_path, included

Methods included from Publishable

included

Class Method Details

.currentObject

Returns the current controller from the context thread local variable.



45
46
47
# File 'lib/nitro/controller.rb', line 45

def self.current
  Thread.current[:CURRENT_CONTROLLER] 
end

.mounted(path) ⇒ Object

This callback is called after the Controller is mounted.



31
32
33
34
35
36
37
38
39
40
# File 'lib/nitro/controller.rb', line 31

def self.mounted(path)
  # Resolve aspects.
  
  Aspects.include_advice_modules(self)
    
  # The scaffolding code is compiled after the mount, so 
  # that template roots are finalized.
  
  compile_scaffolding_code()
end

.replace_current(controller) ⇒ Object

– Replaces the current controller (helper for render). This is an internal method. ++



54
55
56
57
58
# File 'lib/nitro/controller.rb', line 54

def self.replace_current(controller) # :nodoc:
  old = Thread.current[:CURRENT_CONTROLLER]
  Thread.current[:CURRENT_CONTROLLER] = controller
  return old
end