Class: RackStep::Controller

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

Direct Known Subclasses

ErrorController

Defined Under Namespace

Modules: BasicHttpAuthentication, ErbRendering, HtmlRendering

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeController

Returns a new instance of Controller.



19
20
21
22
23
24
# File 'lib/controller.rb', line 19

def initialize
  @response = RackStep::Response.new
  @response.body = ''
  @response.content_type = 'application/json'
  @response.status = 200
end

Instance Attribute Details

#requestObject

The request will be injected here.



9
10
11
# File 'lib/controller.rb', line 9

def request
  @request
end

#responseObject

The Rack::Response object that will be delivered to the user.



12
13
14
# File 'lib/controller.rb', line 12

def response
  @response
end

#settingsObject

The ‘global’ app settings will be injected here. This may contain references to things that should be initialize only once during the app start (eg: database connection).



17
18
19
# File 'lib/controller.rb', line 17

def settings
  @settings
end

Instance Method Details

#afterObject

RackStep will always execute this method after processing the request of to the specified method. The user may overwrite this method. This can be used to check for logging or any piece of code that must be executed after every request for this controller.



37
38
# File 'lib/controller.rb', line 37

def after
end

#beforeObject

RackStep will always execute this method before delegating the request processing to the specified method. The user may overwrite this method. This can be used to check for access authorization or any piece of code that must be executed before every request for this controller.



30
31
# File 'lib/controller.rb', line 30

def before
end