Class: Penthouse::App

Inherits:
Object
  • Object
show all
Defined in:
lib/penthouse/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, router: Penthouse.configuration.router, runner: Penthouse.configuration.runner) ⇒ App

Returns a new instance of App.

Parameters:

  • app

    the Rack application

  • router (#call) (defaults to: Penthouse.configuration.router)

    the class/proc to use as the router

  • runner (#call) (defaults to: Penthouse.configuration.runner)

    the class/proc to use as the runner



22
23
24
25
26
# File 'lib/penthouse/app.rb', line 22

def initialize(app, router: Penthouse.configuration.router, runner: Penthouse.configuration.runner)
  self.app = app
  self.router = router
  self.runner = runner
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



16
17
18
# File 'lib/penthouse/app.rb', line 16

def app
  @app
end

#routerObject

Returns the value of attribute router.



16
17
18
# File 'lib/penthouse/app.rb', line 16

def router
  @router
end

#runnerObject

Returns the value of attribute runner.



16
17
18
# File 'lib/penthouse/app.rb', line 16

def runner
  @runner
end

Instance Method Details

#call(env) ⇒ void

This method returns an undefined value.

Parameters:

  • env (Hash)

    the environment passed from Rack

Raises:



31
32
33
34
35
36
# File 'lib/penthouse/app.rb', line 31

def call(env)
  request = Rack::Request.new(env)
  runner.call(router.call(request)) do
    app.call(env)
  end
end