Class: BackgroundQueue::ServerLib::Config::Worker

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

Overview

A server entry in the configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_entry) ⇒ Worker

Returns a new instance of Worker.



251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/background_queue/server_lib/config.rb', line 251

def initialize(config_entry)
  if config_entry.nil?
    raise BackgroundQueue::LoadError, "Missing worker url"
  elsif config_entry.kind_of?(String)
    raise BackgroundQueue::LoadError, "Missing worker url" if config_entry.strip.length == 0
    begin
      @uri = URI.parse(config_entry)
    rescue URI::InvalidURIError
      raise BackgroundQueue::LoadError, "Invalid worker url (#{config_entry})"
    end
  else
    raise BackgroundQueue::LoadError, "Invalid data type (#{config_entry.class.name}), expecting String (as a url)"
  end
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



249
250
251
# File 'lib/background_queue/server_lib/config.rb', line 249

def uri
  @uri
end

Instance Method Details

#urlObject



266
267
268
# File 'lib/background_queue/server_lib/config.rb', line 266

def url
  @uri.to_s
end