Class: MiddleSquid::Runner
- Inherits:
-
Object
- Object
- MiddleSquid::Runner
- Defined in:
- lib/middle_squid/runner.rb
Overview
Used internally to start the configured adapter and the internal HTTP server. The handler passed to Builder#run will be called in this context.
Instance Attribute Summary collapse
-
#server ⇒ Server
readonly
Returns the internal HTTP server.
Instance Method Summary collapse
-
#initialize(builder) ⇒ Runner
constructor
A new instance of Runner.
Methods included from Helpers
Methods included from Actions
#accept, #intercept, #redirect_to, #replace_by
Constructor Details
#initialize(builder) ⇒ Runner
Returns a new instance of Runner.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/middle_squid/runner.rb', line 17 def initialize(builder) raise Error, 'Invalid handler. Did you call Builder#run in your configuration file?' unless builder.handler define_singleton_method :_handler_wrapper, builder.handler builder.custom_actions.each {|name, body| define_singleton_method name, body } adapter = builder.adapter adapter.handler = method :_handler_wrapper @server = Server.new EM.run { adapter.start @server.start } end |
Instance Attribute Details
#server ⇒ Server (readonly)
Returns the internal HTTP server.
14 15 16 |
# File 'lib/middle_squid/runner.rb', line 14 def server @server end |