Class: NEC::MockServer::Server
- Inherits:
-
Object
- Object
- NEC::MockServer::Server
- Defined in:
- lib/nec_mock_server/mock_server.rb
Overview
Server class. Represent main class of module #MockServe
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#router ⇒ Object
readonly
Returns the value of attribute router.
Instance Method Summary collapse
-
#initialize(router, application_opts = {}) ⇒ Server
constructor
The method creates new instance of Rack::Server.
-
#run!(port, host = 'localhost') ⇒ Object
The method stars server of instance.
Constructor Details
#initialize(router, application_opts = {}) ⇒ Server
The method creates new instance of Rack::Server
23 24 25 26 |
# File 'lib/nec_mock_server/mock_server.rb', line 23 def initialize(router, application_opts = {}) @router = (router || Router).new(application_opts[:application_name]) @app = Application.new(@router, application_opts) end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
11 12 13 |
# File 'lib/nec_mock_server/mock_server.rb', line 11 def app @app end |
#router ⇒ Object (readonly)
Returns the value of attribute router.
11 12 13 |
# File 'lib/nec_mock_server/mock_server.rb', line 11 def router @router end |
Instance Method Details
#run!(port, host = 'localhost') ⇒ Object
The method stars server of instance
33 34 35 |
# File 'lib/nec_mock_server/mock_server.rb', line 33 def run!(port, host = 'localhost') @server = Rack::Server.start(app: @app, Port: port, Host: host) end |