Skip to content

Instantly share code, notes, and snippets.

@dan5
Forked from makoto/gist:229861
Created Nov 10, 2009
Embed
What would you like to do?
require 'yaml'
# Retains as a constant
CONFIG = YAML.load_file('config.yml')
# or
# Retains as an instance variable.
class Config
def initialize(name)
@name = name
end
def get
@config ||= get_from_disk()
end
private
def get_from_disk
YAML.load_file(@name)
end
end
config = Config.new('config.yml')
p config.get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment