class Reality::Config
Attributes
data[R]
keys[R]
Public Class Methods
new()
click to toggle source
# File lib/reality/config.rb, line 7 def initialize @keys = {} @data = {}.extend Hashie::Extensions::DeepFetch end
Public Instance Methods
fetch(*path)
click to toggle source
# File lib/reality/config.rb, line 20 def fetch(*path) data.deep_fetch(*path){ if (known = @keys[path]) fail KeyError, "Expected #{path.join('.')} to exist in config. It is #{known[:desc]}" else fail KeyError, "Expected #{path.join('.')} to exist in config." end } end
load(str)
click to toggle source
# File lib/reality/config.rb, line 12 def load(str) if File.exists?(str) str = File.read(str) end @data.update(YAML.load(str)) end
register(*path, **opts)
click to toggle source
# File lib/reality/config.rb, line 30 def register(*path, **opts) @keys[path] = opts end