Class: ServiceSkeleton::ConfigVariable

Inherits:
Object
  • Object
show all
Defined in:
lib/service_skeleton/config_variable.rb

Direct Known Subclasses

Boolean, Enum, Float, Integer, KVList, PathList, String, URL, YamlFile

Defined Under Namespace

Classes: Boolean, Enum, Float, Integer, KVList, PathList, String, URL, YamlFile

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/service_skeleton/config_variable.rb', line 5

def name
  @name
end

#valueObject (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