Sha256: 258700bbd414efc6ed1aa744c403919d743534b79dc295d1b056738e199a8941
Contents?: true
Size: 982 Bytes
Versions: 4
Compression:
Stored size: 982 Bytes
Contents
module NYNY class RequestScope attr_reader :request, :response def self.add_helper_module m include m end def initialize request @request = request @response = Response.new '', 200, {'Content-Type' => 'text/html'} end def params request.params end def headers hash={} response.headers.merge! hash end def session request.session end def cookies request.cookies end def status code response.status = code end def halt status, headers={}, body='' response.status = status response.headers.merge! headers response.body = body throw :halt, response end def redirect_to uri, status=302 halt status, {'Location' => uri} end alias_method :redirect, :redirect_to def apply_to &handler response.body = instance_eval(&handler) cookies.each {|k,v| response.set_cookie k,v } response end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
nyny-2.2.1 | lib/nyny/request_scope.rb |
nyny-2.1.1 | lib/nyny/request_scope.rb |
nyny-2.1.0 | lib/nyny/request_scope.rb |
nyny-2.0.0 | lib/nyny/request_scope.rb |