class Tansu::Environment
Constants
- IS_RESPOND_TO_EACH
Attributes
params[R]
Public Class Methods
new(request, response = nil)
click to toggle source
Calls superclass method
# File lib/tansu/environment.rb, line 9 def initialize(request, response = nil) @params = parse(request) super request, response end
Public Instance Methods
bind(val)
click to toggle source
Calls superclass method
# File lib/tansu/environment.rb, line 15 def bind(val) res = case val when Response, Minicontext::Halt val when IS_RESPOND_TO_EACH response.body = val response when Fixnum response.status = val response when String response.body = [val] response else nil end super res end
headers(hash = nil)
click to toggle source
# File lib/tansu/environment.rb, line 42 def headers(hash = nil) response.headers.merge!(hash) if hash response.headers end
logger()
click to toggle source
# File lib/tansu/environment.rb, line 52 def logger Application[:logger] end
redirect(uri, status = 302)
click to toggle source
# File lib/tansu/environment.rb, line 56 def redirect(uri, status = 302) response.redirect(uri, status) end
session()
click to toggle source
# File lib/tansu/environment.rb, line 48 def session request.session end
short_circuit?()
click to toggle source
Calls superclass method
# File lib/tansu/environment.rb, line 38 def short_circuit? super || redirect? end
Private Instance Methods
indifferent_params(hash)
click to toggle source
# File lib/tansu/environment.rb, line 70 def indifferent_params(hash) indifferent_hash = Hash.new { |h, k| h[k.to_s] if Symbol === k } hash.each_with_object(indifferent_hash) do |(k, v), a| a[k] = Hash === v ? indifferent_params(v) : v end end
parse(request)
click to toggle source
# File lib/tansu/environment.rb, line 66 def parse(request) indifferent_params(request.params).merge(path_info(request.path_info)) end
path_info(path)
click to toggle source
# File lib/tansu/environment.rb, line 78 def path_info(path) { 'path_info' => (path[1..-1] || '').split('/').map(&:to_sym) } end
redirect?()
click to toggle source
# File lib/tansu/environment.rb, line 62 def redirect? Response === @response && @response.status == 302 end