makoto (owner)

Revisions

gist: 228705 Download_button fork
public
Public Clone URL: git://gist.github.com/228705.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'YAML'
 
class ConfigReader
  def initialize(name)
    @name = name
  end
  
  def config
    @config ||= get_from_disk
  end
 
private
  def get_from_disk
    p "this should be printed only once if cached"
    data = File.open('config.yml')
    YAML.load(data)
  end
end
 
Config = ConfigReader.new('config.yml')
p Config.config
p Config.config