Class: Carpool::Driver

Inherits:
Object
  • Object
show all
Includes:
Mixins::Core
Defined in:
lib/carpool/driver.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Core

included

Constructor Details

#initialize(app) {|Carpool::Driver| ... } ⇒ Driver

Returns a new instance of Driver.

Yields:



24
25
26
27
28
29
# File 'lib/carpool/driver.rb', line 24

def initialize(app)
  @app = app
  Carpool.acts_as = :driver
  yield Carpool::Driver if block_given?
  self
end

Class Attribute Details

.revoke_uriObject

Returns the value of attribute revoke_uri.



12
13
14
# File 'lib/carpool/driver.rb', line 12

def revoke_uri
  @revoke_uri
end

.unauthorized_uriObject

Returns the value of attribute unauthorized_uri.



11
12
13
# File 'lib/carpool/driver.rb', line 11

def unauthorized_uri
  @unauthorized_uri
end

Class Method Details

.passenger(url, secret) ⇒ Object



18
19
20
# File 'lib/carpool/driver.rb', line 18

def passenger(url, secret)
  passengers << { :host => url, :secret => secret }
end

.passengersObject



14
15
16
# File 'lib/carpool/driver.rb', line 14

def passengers
  @passengers ||= []
end

Instance Method Details

#call(env) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/carpool/driver.rb', line 31

def call(env)
  @env = env      
  
  env['carpool'] = Carpool::Seatbelt.new(env) unless env['carpool'] && env['carpool'] != Carpool::Seatbelt
  return revoke_all_instances! if is_revoking?       

  if valid_request?
    manager.auth_request!
    unless manager.authentication_exists?
      return Carpool::Responder.authenticate
    end
  end      
  
  result = catch(:carpool) do
    @app.call(env)
  end
  
  return result

end