Module: Renee::Core::RequestContext
- Included in:
- Renee::Core
- Defined in:
- lib/renee_core/request_context.rb
Overview
This module deals with the Rack#call compilance. It defines #call and also defines several critical methods used by interaction by other application modules.
Instance Attribute Summary collapse
-
#detected_extension ⇒ Object
readonly
Returns the value of attribute detected_extension.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Provides a rack interface compliant call method.
Instance Attribute Details
#detected_extension ⇒ Object (readonly)
Returns the value of attribute detected_extension.
6 7 8 |
# File 'lib/renee_core/request_context.rb', line 6 def detected_extension @detected_extension end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
6 7 8 |
# File 'lib/renee_core/request_context.rb', line 6 def env @env end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/renee_core/request_context.rb', line 6 def request @request end |
Instance Method Details
#call(env) ⇒ Object
Provides a rack interface compliant call method. @param[Hash] env The rack environment.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/renee_core/request_context.rb', line 10 def call(env) @env, @request = env, Rack::Request.new(env) @detected_extension = env['PATH_INFO'][/\.([^\.\/]+)$/, 1] # TODO clear template cache in development? `template_cache.clear` catch(:halt) do begin instance_eval(&self.class.application_block) rescue ClientError => e e.response ? instance_eval(&e.response) : halt("There was an error with your request", 400) end Renee::Core::Response.new("Not found", 404).finish end end |