Class: Rack::Handler::Toycol

Inherits:
Object
  • Object
show all
Extended by:
Toycol::Helper
Defined in:
lib/rack/handler/toycol.rb

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Toycol::Helper

logger

Class Attribute Details

.host=(value) ⇒ Object (writeonly)

Sets the attribute host

Parameters:

  • value

    the value to set the attribute host to.



11
12
13
# File 'lib/rack/handler/toycol.rb', line 11

def host=(value)
  @host = value
end

.port=(value) ⇒ Object (writeonly)

Sets the attribute port

Parameters:

  • value

    the value to set the attribute port to.



11
12
13
# File 'lib/rack/handler/toycol.rb', line 11

def port=(value)
  @port = value
end

.preferred_background_server=(value) ⇒ Object (writeonly)

Sets the attribute preferred_background_server

Parameters:

  • value

    the value to set the attribute preferred_background_server to.



11
12
13
# File 'lib/rack/handler/toycol.rb', line 11

def preferred_background_server=(value)
  @preferred_background_server = value
end

Class Method Details

.run(app, _ = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rack/handler/toycol.rb', line 13

def run(app, _ = {})
  @app = app
  @host ||= ::Toycol::DEFAULT_HOST
  @port ||= "9292"

  if (child_pid = fork)
    ::Toycol::Proxy.new(@host, @port).start
    Process.waitpid(child_pid)
  else
    run_background_server
  end
end