Created
March 20, 2012 02:12
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@postpostmodern that certainly helped clean things up a bit: wyattdanger/YAML-Reader@a6e1ab5