This file contains 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
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