Class: Shinq::Configuration
- Inherits:
-
Object
- Object
- Shinq::Configuration
- Defined in:
- lib/shinq/configuration.rb
Constant Summary collapse
- DEFAULT =
{ require: '.', process: 1, queue_timeout: 1, daemonize: false }
Instance Attribute Summary collapse
-
#daemonize ⇒ Object
Returns the value of attribute daemonize.
-
#db_config ⇒ Object
Returns the value of attribute db_config.
-
#default_db ⇒ Object
Returns the value of attribute default_db.
-
#lifecycle ⇒ Object
Returns the value of attribute lifecycle.
-
#process ⇒ Object
Returns the value of attribute process.
-
#queue_db ⇒ Object
Returns the value of attribute queue_db.
-
#queue_timeout ⇒ Object
Returns the value of attribute queue_timeout.
-
#require ⇒ Object
Returns the value of attribute require.
-
#statistics ⇒ Object
Returns the value of attribute statistics.
-
#worker_name ⇒ Object
Returns the value of attribute worker_name.
Instance Method Summary collapse
- #db_defined?(db_name) ⇒ Boolean
- #default_db_config ⇒ Object
-
#initialize(opts) ⇒ Configuration
constructor
A new instance of Configuration.
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
#daemonize ⇒ Object
Returns the value of attribute daemonize.
5 6 7 |
# File 'lib/shinq/configuration.rb', line 5 def daemonize @daemonize end |
#db_config ⇒ Object
Returns the value of attribute db_config.
5 6 7 |
# File 'lib/shinq/configuration.rb', line 5 def db_config @db_config end |
#default_db ⇒ Object
Returns the value of attribute default_db.
5 6 7 |
# File 'lib/shinq/configuration.rb', line 5 def default_db @default_db end |
#lifecycle ⇒ Object
Returns the value of attribute lifecycle.
5 6 7 |
# File 'lib/shinq/configuration.rb', line 5 def lifecycle @lifecycle end |
#process ⇒ Object
Returns the value of attribute process.
5 6 7 |
# File 'lib/shinq/configuration.rb', line 5 def process @process end |
#queue_db ⇒ Object
Returns the value of attribute queue_db.
5 6 7 |
# File 'lib/shinq/configuration.rb', line 5 def queue_db @queue_db end |
#queue_timeout ⇒ Object
Returns the value of attribute queue_timeout.
5 6 7 |
# File 'lib/shinq/configuration.rb', line 5 def queue_timeout @queue_timeout end |
#require ⇒ Object
Returns the value of attribute require.
5 6 7 |
# File 'lib/shinq/configuration.rb', line 5 def require @require end |
#statistics ⇒ Object
Returns the value of attribute statistics.
5 6 7 |
# File 'lib/shinq/configuration.rb', line 5 def statistics @statistics end |
#worker_name ⇒ Object
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
25 26 27 |
# File 'lib/shinq/configuration.rb', line 25 def db_defined?(db_name) !!(db_config && db_config[db_name]) end |
#default_db_config ⇒ Object
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 |