Class: Sanford::HostData
- Inherits:
-
Object
- Object
- Sanford::HostData
- Defined in:
- lib/sanford/host_data.rb
Instance Attribute Summary collapse
-
#error_proc ⇒ Object
readonly
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server.
-
#ip ⇒ Object
readonly
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server.
-
#logger ⇒ Object
readonly
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server.
-
#name ⇒ Object
readonly
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server.
-
#pid_dir ⇒ Object
readonly
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server.
-
#port ⇒ Object
readonly
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server.
-
#verbose ⇒ Object
readonly
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server.
Instance Method Summary collapse
- #handler_class_for(version, service) ⇒ Object
-
#initialize(service_host, options = nil) ⇒ HostData
constructor
A new instance of HostData.
Constructor Details
#initialize(service_host, options = nil) ⇒ HostData
Returns a new instance of HostData.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sanford/host_data.rb', line 15 def initialize(service_host, = nil) configuration = service_host.configuration.to_hash.merge(remove_nil_values( || {})) @name = configuration[:name] @ip, @port = configuration[:ip], configuration[:port] @pid_dir = configuration[:pid_dir] @logger, @verbose = configuration[:logger], configuration[:verbose_logging] @error_proc = configuration[:error_proc] @handlers = service_host.versioned_services.inject({}) do |hash, (version, services)| hash.merge({ version => self.constantize_services(services) }) end raise Sanford::InvalidHostError.new(service_host) if !self.port end |
Instance Attribute Details
#error_proc ⇒ Object (readonly)
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.
13 14 15 |
# File 'lib/sanford/host_data.rb', line 13 def error_proc @error_proc end |
#ip ⇒ Object (readonly)
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.
13 14 15 |
# File 'lib/sanford/host_data.rb', line 13 def ip @ip end |
#logger ⇒ Object (readonly)
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.
13 14 15 |
# File 'lib/sanford/host_data.rb', line 13 def logger @logger end |
#name ⇒ Object (readonly)
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.
13 14 15 |
# File 'lib/sanford/host_data.rb', line 13 def name @name end |
#pid_dir ⇒ Object (readonly)
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.
13 14 15 |
# File 'lib/sanford/host_data.rb', line 13 def pid_dir @pid_dir end |
#port ⇒ Object (readonly)
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.
13 14 15 |
# File 'lib/sanford/host_data.rb', line 13 def port @port end |
#verbose ⇒ Object (readonly)
When trying to run a server for a host, we need to build up the host’s data to increase the performance of the server. This is done by constantizing a host’s handlers and merging a host’s configuration with optional overrides.
13 14 15 |
# File 'lib/sanford/host_data.rb', line 13 def verbose @verbose end |
Instance Method Details
#handler_class_for(version, service) ⇒ Object
31 32 33 34 |
# File 'lib/sanford/host_data.rb', line 31 def handler_class_for(version, service) version_group = @handlers[version] || {} version_group[service] || raise(Sanford::NotFoundError) end |