Method: Experiment::Config.get
- Defined in:
- lib/experiment/config.rb
.get(key) ⇒ Object .get(key, default) ⇒ Object .get(key, default = nil, interpolations) ⇒ Object
Allows access to any config option by key. Supports Interploations. Interpolations are supported as opts argument
Words preceded with a colon (:) are interpolated
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/experiment/config.rb', line 104 def get(v, *opts) @used ||= [] @used << v.to_s default = opts.shift if opts.length == 2 || !opts.first.is_a?(Hash) out = @config[v.to_s] || default if opts = opts.first opts.keys.reduce(out.dup) do |result, inter| result.gsub /:#{inter}/, opts[inter] end else out end end |