Sha256: 06799735a6b26b13a577869f7fd23fdea3f0cd58532c5f41d1f5307bf8640977
Contents?: true
Size: 862 Bytes
Versions: 14
Compression:
Stored size: 862 Bytes
Contents
module Climatic module ConfigLayers class EnvLayer < SuperStack::Layer attr_reader :filter def initialize(filter=nil) self.filter = filter end def filter=(filter) raise 'Invalid filter' unless [NilClass, String, Array, Regexp].include? filter.class @filter = filter load end def load(*args) self.replace read_filtered_environment @file_name = :none self end private def read_filtered_environment return ENV.to_hash if filter.nil? if filter.is_a? Array ENV.to_hash.select {|k, v| filter.include?(k) } elsif filter.is_a? Regexp ENV.to_hash.select {|k, v| k =~ filter } elsif filter.is_a? String ENV.to_hash.select {|k, v| k == filter } end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems