Module: BeanStalk::Worker::Config
- Extended by:
- Mixlib::Config
- Defined in:
- lib/beanstalk-worker/config.rb
Class Method Summary collapse
-
.base_merge! ⇒ Object
Support merging via coercion to symbols.
-
.beanstalk_uri ⇒ String
Helper method for generation the beanstalk uri.
-
.from_file(filename, opts = {}) ⇒ Object
Loads a given file and passes it to the appropriate parser.
-
.from_file_json(filename, *args) ⇒ Object
Loads a given json file and merges the current context configuration with the updated hash.
-
.from_file_ruby(filename, *args) ⇒ Object
Loads a given ruby file and runs instance_eval against it in the context of the current object.
-
.from_file_yaml(filename, environment) ⇒ Object
Loads a given yaml file and merges the current context configuration with the updated hash.
-
.from_stream_json(input, *args) ⇒ Object
Loads a given json input and merges the current context configuration with the updated hash.
-
.inspect ⇒ Object
Return the configuration itself upon inspection.
- .merge!(hash) ⇒ Object
Class Method Details
.base_merge! ⇒ Object
Support merging via coercion to symbols.
22 |
# File 'lib/beanstalk-worker/config.rb', line 22 alias :base_merge! :merge! |
.beanstalk_uri ⇒ String
Helper method for generation the beanstalk uri
88 89 90 |
# File 'lib/beanstalk-worker/config.rb', line 88 def self.beanstalk_uri [self[:beanstalk][:server], self[:beanstalk][:port]].join(":") end |
.from_file(filename, opts = {}) ⇒ Object
Loads a given file and passes it to the appropriate parser.
34 35 36 37 38 |
# File 'lib/beanstalk-worker/config.rb', line 34 def self.from_file(filename, opts={}) opts = { :parser => "yaml" }.merge(opts) send("from_file_#{opts[:parser]}".to_sym, filename, (opts[:environment] || self[:environment])) end |
.from_file_json(filename, *args) ⇒ Object
Loads a given json file and merges the current context configuration with the updated hash.
69 70 71 |
# File 'lib/beanstalk-worker/config.rb', line 69 def self.from_file_json(filename, *args) self.from_stream_json(IO.read(filename)) end |
.from_file_ruby(filename, *args) ⇒ Object
Loads a given ruby file and runs instance_eval against it in the context of the current object.
46 47 48 |
# File 'lib/beanstalk-worker/config.rb', line 46 def self.from_file_ruby(filename, *args) self.instance_eval(IO.read(filename), filename, 1) end |
.from_file_yaml(filename, environment) ⇒ Object
Loads a given yaml file and merges the current context configuration with the updated hash.
58 59 60 |
# File 'lib/beanstalk-worker/config.rb', line 58 def self.from_file_yaml(filename, environment) merge!(YAML.load_file(filename).deep_symbolize_keys[environment]) end |
.from_stream_json(input, *args) ⇒ Object
Loads a given json input and merges the current context configuration with the updated hash.
80 81 82 83 |
# File 'lib/beanstalk-worker/config.rb', line 80 def self.from_stream_json(input, *args) parser = Yajl::Parser.new(:symbolize_keys => true) merge!(parser.parse(input)) end |
.inspect ⇒ Object
Return the configuration itself upon inspection.
12 13 14 |
# File 'lib/beanstalk-worker/config.rb', line 12 def self.inspect configuration.inspect end |
.merge!(hash) ⇒ Object
23 24 25 |
# File 'lib/beanstalk-worker/config.rb', line 23 def merge!(hash) base_merge!(configuration.deep_merge(hash.deep_symbolize_keys)) end |