Class: Waw::Controller

Inherits:
Object show all
Includes:
Rack::Delegator, EnvironmentUtils
Defined in:
lib/waw/controller.rb

Overview

Controller of a web application, designing a number of typical services.

Constant Summary

Constants included from EnvironmentUtils

EnvironmentUtils::DEPRECATED_MSG

Instance Method Summary collapse

Methods included from Rack::Delegator

#_visit, #delegate, #find_rack_app, #find_url_of, #has_delegate?, #is_delegate?, #visit

Methods included from EnvironmentUtils

#env, #session_get, #session_has_key?, #session_set, #session_unset

Methods included from ScopeUtils

#config, #find_kernel_context, #logger, #params, #rack_env, #real_session, #request, #resources, #response, #root_folder, #session

Instance Method Details

#call(env) ⇒ Object

Handler for Rack calls to the controller

Raises:



11
12
13
14
15
16
# File 'lib/waw/controller.rb', line 11

def call(env)
  result = execute(env, request, response)
  raise WawError, "Controller #{self.class} returned an empty result" unless result
  raise WawError, "Controller #{self.class} returned an invalid result #{result.inspect}" unless Array===result
  result
end

#execute(env, request, response) ⇒ Object

Executes the controller on a Rack::Request and Rack::Response pair



19
20
21
# File 'lib/waw/controller.rb', line 19

def execute(env, request, response)
  raise "Should be subclassed"
end