Sha256: 3dc6508a03e94c7fc973ea3913ce8db65be4ccb873e159e811a48fa421def4a6
Contents?: true
Size: 842 Bytes
Versions: 1
Compression:
Stored size: 842 Bytes
Contents
require 'yaml' module Configature::Support # == Module and Mixin Methods ============================================= def yaml_if_exist(path) return unless (File.exist?(path)) File.open(path) do |f| YAML.safe_load(f, aliases: true) or { } end end def extend_env_prefix(base, with) return base unless (base) return with unless (with) case (base) when '' with.to_s.upcase else base.upcase + '_' + with.to_s.upcase end end def convert_hashes(to_class, obj) case (obj) when Hash, OpenStruct, Configature::Data to_class.new( obj.to_h.map do |k, v| [ k, convert_hashes(to_class, v) ] end.to_h ) when Array obj.map do |v| convert_hashes(to_class, v) end else obj end end extend self end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
configature-0.3.7 | lib/configature/support.rb |