diff options
Diffstat (limited to 'lib/rainbows/http_server.rb')
-rw-r--r-- | lib/rainbows/http_server.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/rainbows/http_server.rb b/lib/rainbows/http_server.rb index 8ed8fa2..8fdecb6 100644 --- a/lib/rainbows/http_server.rb +++ b/lib/rainbows/http_server.rb @@ -15,30 +15,30 @@ module Rainbows def initialize(app, options) @@instance = self + @worker_connections = 1 rv = super(app, options) - defined?(@use) or use(:ThreadPool) - defined?(@worker_connections) or worker_connections(4) - rv + defined?(@use) or use(:Base) end def use(*args) - return @use if args.empty? - model = begin - Rainbows.const_get(args.first) + model = args.shift or return @use + mod = begin + Rainbows.const_get(model) rescue NameError raise ArgumentError, "concurrency model #{model.inspect} not supported" end - Module === model or + Module === mod or raise ArgumentError, "concurrency model #{model.inspect} not supported" - extend(@use = model) + extend(mod) + @use = model end def worker_connections(*args) return @worker_connections if args.empty? nr = args.first - (Integer === nr && nr > 0) || nr.nil? or - raise ArgumentError, "worker_connections must be an Integer or nil" + (Integer === nr && nr > 0) or + raise ArgumentError, "worker_connections must be a positive Integer" @worker_connections = nr end |