Class: HerokuResqueAutoscaler::Configuration
- Inherits:
-
Object
- Object
- HerokuResqueAutoscaler::Configuration
- Defined in:
- lib/heroku_resque_autoscaler/configuration.rb
Constant Summary collapse
- OPTIONS =
{ heroku_api_key: ENV["HEROKU_API_KEY"], heroku_app_name: ENV["HEROKU_APP_NAME"], max_resque_workers: ENV["MAX_RESQUE_WORKERS"] }
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
-
#initialize ⇒ Configuration
constructor
Initializes defaults to be the environment variables of the same names.
-
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with
hash
. -
#to_hash ⇒ Object
Returns a hash of all configurable options.
Constructor Details
#initialize ⇒ Configuration
Initializes defaults to be the environment variables of the same names
15 16 17 18 19 |
# File 'lib/heroku_resque_autoscaler/configuration.rb', line 15 def initialize OPTIONS.each_pair do |key, value| self.send("#{key}=", value) end end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
24 25 26 |
# File 'lib/heroku_resque_autoscaler/configuration.rb', line 24 def [](option) send(option) end |
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with hash
precedence over the defaults
41 42 43 |
# File 'lib/heroku_resque_autoscaler/configuration.rb', line 41 def merge(hash) to_hash.merge(hash) end |
#to_hash ⇒ Object
Returns a hash of all configurable options
29 30 31 32 33 34 35 |
# File 'lib/heroku_resque_autoscaler/configuration.rb', line 29 def to_hash OPTIONS.inject({}) do |hash, option| key = option.first hash[key] = self.send(key) hash end end |