Skip to content

Instantly share code, notes, and snippets.

@wyattdanger
Created March 20, 2012 02:12
Show Gist options
  • Save wyattdanger/2130136 to your computer and use it in GitHub Desktop.
Save wyattdanger/2130136 to your computer and use it in GitHub Desktop.
class that accepts a yaml file and dynamically creates getters/setters for each yaml key
class YAMLReader
def initialize yaml_file_path
YAML.load_file(yaml_file_path).each do |key, value|
self.class.instance_eval do
attr_accessor :"#{key}"
end
self.send "#{key}=", value
end
end
end
@wyattdanger
Copy link
Author

@postpostmodern that certainly helped clean things up a bit: wyattdanger/YAML-Reader@a6e1ab5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment