Sha256: 89b6484eed1da619ec90af37cf5bc90d09f7df6fabed04e7b32e92abdc819f71
Contents?: true
Size: 820 Bytes
Versions: 6
Compression:
Stored size: 820 Bytes
Contents
# frozen_string_literal: true require 'yaml' require 'erb' module Econfig class YAML def initialize(path) @path = path @mutex = Mutex.new @options = nil end def keys Set.new(options.keys) end def get(key) options[key] end def has_key?(key) options.key?(key) end private def path raise Econfig::UninitializedError, 'Econfig.root is not set' unless Econfig.root File.expand_path(@path, Econfig.root) end def options return @options if @options @mutex.synchronize do @options ||= if File.exist?(path) ::YAML.load(::ERB.new(File.read(path)).result)[Econfig.env] || {} else {} end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems