Skip to content

Instantly share code, notes, and snippets.

@dan5
Forked from makoto/gist:229861
Created November 10, 2009 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dan5/230557 to your computer and use it in GitHub Desktop.
Save dan5/230557 to your computer and use it in GitHub Desktop.
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