Class: Carpool::Passenger

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

Class Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Core

included

Constructor Details

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

Returns a new instance of Passenger.

Yields:



13
14
15
16
17
18
# File 'lib/carpool/passenger.rb', line 13

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

Class Attribute Details

.driver_uriObject

Returns the value of attribute driver_uri.



8
9
10
# File 'lib/carpool/passenger.rb', line 8

def driver_uri
  @driver_uri
end

.secretObject

Returns the value of attribute secret.



9
10
11
# File 'lib/carpool/passenger.rb', line 9

def secret
  @secret
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/carpool/passenger.rb', line 20

def call(env)
  @env = env
  
  env['carpool'] = Carpool::Seatbelt.new(env) unless env['carpool'] && env['carpool'] != Carpool::Seatbelt
  
  return @app.call(env) unless valid_request?
  result = catch(:carpool) do
    @app.call(env)
  end
  return result
  
end