Class: BackgroundQueue::ClientLib::Config::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/background_queue/client_lib/config.rb

Overview

A server entry in the configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_entry) ⇒ Server

Returns a new instance of Server.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/background_queue/client_lib/config.rb', line 91

def initialize(config_entry)
  if config_entry.kind_of?(Hash)
    @host = BackgroundQueue::Utils.get_hash_entry(config_entry, :host)
    raise BackgroundQueue::LoadError, "Missing 'host' configuration entry" if @host.nil?
  
    @port = BackgroundQueue::Utils.get_hash_entry(config_entry, :port)
    if @port
      @port = @port.to_i
    else
      @port = BackgroundQueue::Config::DEFAULT_PORT 
    end
  else
    raise BackgroundQueue::LoadError, "Invalid data type (#{config_entry.class.name}), expecting Hash"
  end
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



88
89
90
# File 'lib/background_queue/client_lib/config.rb', line 88

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



89
90
91
# File 'lib/background_queue/client_lib/config.rb', line 89

def port
  @port
end