Class: ServiceSkeleton::ConfigVariable
- Inherits:
-
Object
- Object
- ServiceSkeleton::ConfigVariable
- Defined in:
- lib/service_skeleton/config_variable.rb
Defined Under Namespace
Classes: Boolean, Enum, Float, Integer, KVList, PathList, String, URL, YamlFile
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, env, **opts, &blk) ⇒ ConfigVariable
constructor
A new instance of ConfigVariable.
- #method_name(svc_name) ⇒ Object
- #redact!(env) ⇒ Object
- #redact?(env) ⇒ Boolean
Constructor Details
#initialize(name, env, **opts, &blk) ⇒ ConfigVariable
7 8 9 10 11 12 13 |
# File 'lib/service_skeleton/config_variable.rb', line 7 def initialize(name, env, **opts, &blk) @name = name @opts = opts @blk = blk @value = pluck_value(env) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/service_skeleton/config_variable.rb', line 5 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/service_skeleton/config_variable.rb', line 5 def value @value end |
Instance Method Details
#method_name(svc_name) ⇒ Object
15 16 17 |
# File 'lib/service_skeleton/config_variable.rb', line 15 def method_name(svc_name) @name.to_s.gsub(/\A#{Regexp.quote(svc_name)}_/i, '').downcase end |
#redact!(env) ⇒ Object
23 24 25 26 27 |
# File 'lib/service_skeleton/config_variable.rb', line 23 def redact!(env) if @opts[:sensitive] env[@name.to_s] = "*SENSITIVE*" if env.has_key?(@name.to_s) end end |
#redact?(env) ⇒ Boolean
19 20 21 |
# File 'lib/service_skeleton/config_variable.rb', line 19 def redact?(env) @opts[:sensitive] end |