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, parser = "yaml") ⇒ 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
86 87 88 |
# File 'lib/beanstalk-worker/config.rb', line 86 def self.beanstalk_uri [self[:beanstalk][:server], self[:beanstalk][:port]].join(":") end |
.from_file(filename, parser = "yaml") ⇒ Object
Loads a given file and passes it to the appropriate parser.
34 35 36 |
# File 'lib/beanstalk-worker/config.rb', line 34 def self.from_file(filename, parser="yaml") send("from_file_#{parser}".to_sym, filename, self[:environment]) end |
.from_file_json(filename, *args) ⇒ Object
Loads a given json file and merges the current context configuration with the updated hash.
67 68 69 |
# File 'lib/beanstalk-worker/config.rb', line 67 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.
44 45 46 |
# File 'lib/beanstalk-worker/config.rb', line 44 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.
56 57 58 |
# File 'lib/beanstalk-worker/config.rb', line 56 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.
78 79 80 81 |
# File 'lib/beanstalk-worker/config.rb', line 78 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 |