Class: Waitress::Configuration
- Inherits:
-
Object
- Object
- Waitress::Configuration
- Defined in:
- lib/waitress/configure.rb
Overview
The Configuration Class is the object that contains a configuration of a single server instance, hosting all the methods provided by Waitress.configure!
Instance Attribute Summary collapse
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#ports ⇒ Object
Returns the value of attribute ports.
-
#processes ⇒ Object
Returns the value of attribute processes.
Instance Method Summary collapse
-
#all_hosts(&block) ⇒ Object
Over all the registered VHosts, call this method.
-
#host(regex, priority = 50, &block) ⇒ Object
Create a new VirtualHost with the given regex, priority, and configure it inside of its own block.
-
#initialize(configure, *ports) ⇒ Configuration
constructor
A new instance of Configuration.
-
#less_watch(time) ⇒ Object
Set the watch period for the LESS Watcher, i.e.
- #to_s ⇒ Object
Constructor Details
#initialize(configure, *ports) ⇒ Configuration
Returns a new instance of Configuration.
88 89 90 91 92 93 94 95 |
# File 'lib/waitress/configure.rb', line 88 def initialize configure, *ports @ports = *ports @hosts = [] @configure = configure @processes = 5 @processes = ENV["WAITRESS_PROCESSES"].to_i if ENV.include? "WAITRESS_PROCESSES" end |
Instance Attribute Details
#hosts ⇒ Object
Returns the value of attribute hosts.
84 85 86 |
# File 'lib/waitress/configure.rb', line 84 def hosts @hosts end |
#ports ⇒ Object
Returns the value of attribute ports.
85 86 87 |
# File 'lib/waitress/configure.rb', line 85 def ports @ports end |
#processes ⇒ Object
Returns the value of attribute processes.
86 87 88 |
# File 'lib/waitress/configure.rb', line 86 def processes @processes end |
Instance Method Details
#all_hosts(&block) ⇒ Object
Over all the registered VHosts, call this method. Use this to configure a similar setting for all vhosts at once instead of duplicating code across all of them.
110 111 112 |
# File 'lib/waitress/configure.rb', line 110 def all_hosts &block @hosts.each { |h| block.call(h) } end |
#host(regex, priority = 50, &block) ⇒ Object
Create a new VirtualHost with the given regex, priority, and configure it inside of its own block.
99 100 101 102 103 104 105 |
# File 'lib/waitress/configure.rb', line 99 def host regex, priority=50, &block host = Waitress::Vhost.new regex, priority host.set_configure @configure block.call(host) @hosts << host host end |
#less_watch(time) ⇒ Object
Set the watch period for the LESS Watcher, i.e. how long to sleep before checking LESS files for an update and recompile
116 117 118 |
# File 'lib/waitress/configure.rb', line 116 def less_watch time Waitress::LESSWatcher.set_time time end |
#to_s ⇒ Object
120 121 122 123 |
# File 'lib/waitress/configure.rb', line 120 def to_s m = lambda { |a,x| x.nil? ? "" : "\r\n#{a}=#{x.inspect}" } "#<#{self.class} #{m.call('ports', @ports)} #{m.call('hosts', @hosts)}>" end |