Skip to content

Instantly share code, notes, and snippets.

@gerep
Created August 17, 2015 17:19
Show Gist options
  • Save gerep/40b27c35c43be3c9ff50 to your computer and use it in GitHub Desktop.
Save gerep/40b27c35c43be3c9ff50 to your computer and use it in GitHub Desktop.
# READS A .yml FILE AND FOR EACH KEY IT WILL CREATE A GETTER AND SETTER METHODS
class Flag
def initialize
@yaml = Psych.load_file('config/flags.yml')
@yaml.each_key do |item|
self.class.send(:define_method, item) { @yaml[item] }
self.class.send(:define_method, "#{item}=") { |value| @yaml[item] = value }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment