Class: Freddie::Context
- Inherits:
-
Object
- Object
- Freddie::Context
- Defined in:
- lib/freddie/context.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #current_user ⇒ Object
-
#initialize(env) ⇒ Context
constructor
A new instance of Context.
- #session ⇒ Object
Constructor Details
#initialize(env) ⇒ Context
Returns a new instance of Context.
5 6 7 8 9 10 11 |
# File 'lib/freddie/context.rb', line 5 def initialize(env) @request = Rack::Request.new(env) @response = Rack::Response.new @params = @request.params.with_indifferent_access @path = @request.path.gsub(/^\//, '').split('/') @finished = false end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/freddie/context.rb', line 3 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/freddie/context.rb', line 3 def path @path end |
#request ⇒ Object
Returns the value of attribute request.
3 4 5 |
# File 'lib/freddie/context.rb', line 3 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/freddie/context.rb', line 3 def response @response end |
Instance Method Details
#current_user ⇒ Object
13 14 15 |
# File 'lib/freddie/context.rb', line 13 def current_user session['omniauth_user'].try(:last) end |
#session ⇒ Object
17 18 19 |
# File 'lib/freddie/context.rb', line 17 def session request.session end |