Class: Fake::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/fake/service.rb

Instance Method Summary collapse

Constructor Details

#initialize(port: 8080, bind: "localhost") ⇒ Service

Returns a new instance of Service.



3
4
5
6
7
# File 'lib/fake/service.rb', line 3

def initialize(port:8080, bind:"localhost")
  @app = RackApp.new
  @webrick_config = {Port:port, BindAddress:bind}
  @server = Server.new
end

Instance Method Details

#add_request_handler(request_handler) ⇒ Object



9
10
11
# File 'lib/fake/service.rb', line 9

def add_request_handler(request_handler)
  @app.add_request_handler(request_handler)
end

#clearObject



21
22
23
# File 'lib/fake/service.rb', line 21

def clear
  @app.clear_request_handlers
end

#startObject



13
14
15
# File 'lib/fake/service.rb', line 13

def start
  @server.start(@app, @webrick_config)
end

#stopObject



17
18
19
# File 'lib/fake/service.rb', line 17

def stop
  @server.stop
end