Class: Freddie::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/freddie/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#paramsObject

Returns the value of attribute params.



3
4
5
# File 'lib/freddie/context.rb', line 3

def params
  @params
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/freddie/context.rb', line 3

def path
  @path
end

#requestObject

Returns the value of attribute request.



3
4
5
# File 'lib/freddie/context.rb', line 3

def request
  @request
end

#responseObject

Returns the value of attribute response.



3
4
5
# File 'lib/freddie/context.rb', line 3

def response
  @response
end

Instance Method Details

#current_userObject



13
14
15
# File 'lib/freddie/context.rb', line 13

def current_user
  session['omniauth_user'].try(:last)
end

#sessionObject



17
18
19
# File 'lib/freddie/context.rb', line 17

def session
  request.session
end