Class: Shinq::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/shinq/configuration.rb

Constant Summary collapse

DEFAULT =
{
  require: '.',
  process: 1,
  queue_timeout: 1,
  daemonize: false
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Configuration

Returns a new instance of Configuration.



14
15
16
17
18
# File 'lib/shinq/configuration.rb', line 14

def initialize(opts)
  %i(require worker_name db_config queue_db default_db process queue_timeout daemonize statistics lifecycle).each do |k|
    send(:"#{k}=", opts[k] || DEFAULT[k])
  end
end

Instance Attribute Details

#daemonizeObject

Returns the value of attribute daemonize.



5
6
7
# File 'lib/shinq/configuration.rb', line 5

def daemonize
  @daemonize
end

#db_configObject

Returns the value of attribute db_config.



5
6
7
# File 'lib/shinq/configuration.rb', line 5

def db_config
  @db_config
end

#default_dbObject

Returns the value of attribute default_db.



5
6
7
# File 'lib/shinq/configuration.rb', line 5

def default_db
  @default_db
end

#lifecycleObject

Returns the value of attribute lifecycle.



5
6
7
# File 'lib/shinq/configuration.rb', line 5

def lifecycle
  @lifecycle
end

#processObject

Returns the value of attribute process.



5
6
7
# File 'lib/shinq/configuration.rb', line 5

def process
  @process
end

#queue_dbObject

Returns the value of attribute queue_db.



5
6
7
# File 'lib/shinq/configuration.rb', line 5

def queue_db
  @queue_db
end

#queue_timeoutObject

Returns the value of attribute queue_timeout.



5
6
7
# File 'lib/shinq/configuration.rb', line 5

def queue_timeout
  @queue_timeout
end

#requireObject

Returns the value of attribute require.



5
6
7
# File 'lib/shinq/configuration.rb', line 5

def require
  @require
end

#statisticsObject

Returns the value of attribute statistics.



5
6
7
# File 'lib/shinq/configuration.rb', line 5

def statistics
  @statistics
end

#worker_nameObject

Returns the value of attribute worker_name.



5
6
7
# File 'lib/shinq/configuration.rb', line 5

def worker_name
  @worker_name
end

Instance Method Details

#db_defined?(db_name) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/shinq/configuration.rb', line 25

def db_defined?(db_name)
  !!(db_config && db_config[db_name])
end

#default_db_configObject

Raises:



20
21
22
23
# File 'lib/shinq/configuration.rb', line 20

def default_db_config
  raise ConfigurationError if !(default_db && db_defined?(default_db))
  db_config[default_db]
end