Class: Runkeeper::AuthorizationServer::App

Inherits:
Object
  • Object
show all
Defined in:
lib/runkeeper/token_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ App

Returns a new instance of App.



13
14
15
# File 'lib/runkeeper/token_generator.rb', line 13

def initialize(server)
  @server = server
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



11
12
13
# File 'lib/runkeeper/token_generator.rb', line 11

def code
  @code
end

#envObject (readonly)

Returns the value of attribute env.



11
12
13
# File 'lib/runkeeper/token_generator.rb', line 11

def env
  @env
end

#serverObject (readonly)

Returns the value of attribute server.



11
12
13
# File 'lib/runkeeper/token_generator.rb', line 11

def server
  @server
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/runkeeper/token_generator.rb', line 17

def call(env)
  @env = env
  if params['code']
    @code = params['code']
    [200, { 'Content-Type' => 'text/html' }, ['Check the console for your token.']]
  else
    [404, { 'Content-Type' => 'text/html' }, ['']]
  end
end

#paramsObject



27
28
29
30
31
32
# File 'lib/runkeeper/token_generator.rb', line 27

def params
  @params ||= begin
    ary = env['QUERY_STRING'].split('&').map {|s| s.split('=', 2)}
    Hash[*ary.flatten]
  end
end