Sha256: 304f0ea3b5c0ff46741df69994df7bbb8e32b763a289dce417fb258551207bcb
Contents?: true
Size: 905 Bytes
Versions: 2
Compression:
Stored size: 905 Bytes
Contents
# frozen_string_literal: true class ServiceSkeleton class ConfigVariable attr_reader :name, :value def initialize(name, env, **opts, &blk) @name = name @opts = opts @blk = blk @value = pluck_value(env) end def method_name(svc_name) @name.to_s.gsub(/\A#{Regexp.quote(svc_name)}_/i, '').downcase end def redact?(env) @opts[:sensitive] end def redact!(env) if @opts[:sensitive] env[@name.to_s] = "*SENSITIVE*" if env.has_key?(@name.to_s) end end private def maybe_default(env) if env.has_key?(@name.to_s) yield else if @opts.has_key?(:default) @opts[:default] else raise ServiceSkeleton::Error::InvalidEnvironmentError, "Value for required environment variable #{@name} not specified" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
service_skeleton-0.0.0.44.g75d07d7 | lib/service_skeleton/config_variable.rb |
service_skeleton-0.0.0.43.g678698a | lib/service_skeleton/config_variable.rb |