Class: Webmachine::Adapters::WEBrick

Inherits:
Webmachine::Adapter show all
Defined in:
lib/webmachine/adapters/webrick.rb

Overview

Connects Webmachine to WEBrick.

Defined Under Namespace

Classes: Server

Constant Summary

DEFAULT_OPTIONS =

Used to override default WEBRick options (useful in testing)

{}

Instance Attribute Summary

Attributes inherited from Webmachine::Adapter

#application

Instance Method Summary (collapse)

Methods inherited from Webmachine::Adapter

#initialize, run

Constructor Details

This class inherits a constructor from Webmachine::Adapter

Instance Method Details

- (Object) run

Starts the WEBrick adapter



16
17
18
19
20
21
22
23
24
25
# File 'lib/webmachine/adapters/webrick.rb', line 16

def run
  options = DEFAULT_OPTIONS.merge({
    :Port => application.configuration.port,
    :BindAddress => application.configuration.ip,
    :application => application
  }).merge(application.configuration.adapter_options)
  @server = Server.new(options)
  trap("INT") { shutdown }
  @server.start
end

- (Object) shutdown



27
28
29
# File 'lib/webmachine/adapters/webrick.rb', line 27

def shutdown
  @server.shutdown if @server
end