Class: Fake::Service
- Inherits:
-
Object
- Object
- Fake::Service
- Defined in:
- lib/fake/service.rb
Instance Method Summary collapse
- #add_request_handler(request_handler) ⇒ Object
- #clear ⇒ Object
-
#initialize(port: 8080, bind: "localhost") ⇒ Service
constructor
A new instance of Service.
- #start ⇒ Object
- #stop ⇒ Object
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 |
#clear ⇒ Object
21 22 23 |
# File 'lib/fake/service.rb', line 21 def clear @app.clear_request_handlers end |
#start ⇒ Object
13 14 15 |
# File 'lib/fake/service.rb', line 13 def start @server.start(@app, @webrick_config) end |
#stop ⇒ Object
17 18 19 |
# File 'lib/fake/service.rb', line 17 def stop @server.stop end |