Sha256: 6398a290790e28cc86a19b2a05f54380807b48e020be0a3535fe8ed4e8a6c7b3
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
require 'happy/request' require 'happy/context/helpers' module Happy class Context include Helpers attr_reader :request, :response, :previous_path, :remaining_path attr_accessor :layout, :controller delegate :params, :session, :to => :request def initialize(request, response) @request = request @response = response @remaining_path = @request.path.split('/').reject {|s| s.blank? } @previous_path = [] @layout = nil @controller = nil end def with_controller(new_controller) # remember previous controller old_controller = self.controller self.controller = new_controller # execute permissions block SMELL - better integration if controller.class.respond_to?(:permissions_blk) controller.class.permissions_blk.try(:call, permissions, self) end # execute block yield ensure # switch back to previous controller self.controller = old_controller end def response=(r) @response = r end private class << self def from_env(env) new(Happy::Request.new(env), Rack::Response.new) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
happy-0.1.0.pre12 | lib/happy/context.rb |
happy-0.1.0.pre11 | lib/happy/context.rb |
happy-0.1.0.pre10 | lib/happy/context.rb |