lib/hashr/env_defaults.rb in hashr-0.0.3 vs lib/hashr/env_defaults.rb in hashr-0.0.4
- old
+ new
@@ -1,13 +1,23 @@
class Hashr < Hash
module EnvDefaults
+ attr_writer :env_namespace
+
+ def env_namespace=(env_namespace)
+ @env_namespace = [env_namespace.upcase]
+ end
+
+ def env_namespace
+ @env_namespace ||= []
+ end
+
def definition
deep_enverize(super)
end
protected
- def deep_enverize(hash, nesting = ['WORKER'])
+ def deep_enverize(hash, nesting = env_namespace)
hash.each do |key, value|
nesting << key.to_s.upcase
hash[key] = case value
when Hash
deep_enverize(value, nesting)