lib/woodhouse/node_configuration.rb in woodhouse-0.1.5 vs lib/woodhouse/node_configuration.rb in woodhouse-1.0.0
- old
+ new
@@ -44,9 +44,37 @@
def extension(name, opts = {}, &blk)
Woodhouse::Extension.install_extension(name, self, opts, &blk)
end
+ def load_yaml(path, keyw = {})
+ return unless File.exist?(path)
+
+ section = keyw[:section]
+ environment = keyw[:environment]
+
+ config_info = YAML.load(File.read(path))
+
+ if environment
+ config_info = config_info[environment]
+ end
+ if section
+ config_info = { section => config_info }
+ end
+
+ set config_info
+ end
+
+ def set(hash)
+ return unless hash
+
+ hash.each do |key, val|
+ if respond_to?("#{key}=")
+ send("#{key}=", val)
+ end
+ end
+ end
+
private
def lookup_key(key, namespace)
const = Woodhouse.const_get("#{namespace}s").const_get("#{camelize(key.to_s)}#{namespace}")
unless const