Class: Roy::Context
- Inherits:
-
Object
- Object
- Roy::Context
- Defined in:
- lib/roy/context.rb
Instance Attribute Summary (collapse)
-
- (Object) app
readonly
Returns the value of attribute app.
-
- (Object) conf
readonly
Returns the value of attribute conf.
-
- (Object) env
readonly
Returns the value of attribute env.
-
- (Object) headers
readonly
Returns the value of attribute headers.
-
- (Object) params
readonly
Returns the value of attribute params.
-
- (Object) request
readonly
Returns the value of attribute request.
-
- (Object) response
readonly
Returns the value of attribute response.
Instance Method Summary (collapse)
-
- (Context) initialize(app)
constructor
A new instance of Context.
- - (Object) prepare!(env)
Constructor Details
- (Context) initialize(app)
A new instance of Context
5 6 7 8 9 10 11 12 |
# File 'lib/roy/context.rb', line 5 def initialize(app) @app = app @conf = app.class.conf app.class.ancestors.reverse.each do |mod| mod.setup(self) if mod.respond_to?(:setup) end end |
Instance Attribute Details
- (Object) app (readonly)
Returns the value of attribute app
3 4 5 |
# File 'lib/roy/context.rb', line 3 def app @app end |
- (Object) conf (readonly)
Returns the value of attribute conf
3 4 5 |
# File 'lib/roy/context.rb', line 3 def conf @conf end |
- (Object) env (readonly)
Returns the value of attribute env
3 4 5 |
# File 'lib/roy/context.rb', line 3 def env @env end |
- (Object) headers (readonly)
Returns the value of attribute headers
3 4 5 |
# File 'lib/roy/context.rb', line 3 def headers @headers end |
- (Object) params (readonly)
Returns the value of attribute params
3 4 5 |
# File 'lib/roy/context.rb', line 3 def params @params end |
- (Object) request (readonly)
Returns the value of attribute request
3 4 5 |
# File 'lib/roy/context.rb', line 3 def request @request end |
- (Object) response (readonly)
Returns the value of attribute response
3 4 5 |
# File 'lib/roy/context.rb', line 3 def response @response end |
Instance Method Details
- (Object) prepare!(env)
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/roy/context.rb', line 14 def prepare!(env) @env = env @request = Rack::Request.new(env) @response = Rack::Response.new @headers = @response.header @params = @request.GET.merge(@request.POST) @params.default_proc = proc do |hash, key| hash[key.to_s] if Symbol === key end end |