Class: Kbt::Environment
- Inherits:
-
Object
- Object
- Kbt::Environment
- Defined in:
- lib/kbt/environment.rb
Instance Attribute Summary collapse
-
#overrides ⇒ Object
readonly
Returns the value of attribute overrides.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #format_overrides ⇒ Object
-
#initialize(template, overrides = {}) ⇒ Environment
constructor
A new instance of Environment.
- #override_keys ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(template, overrides = {}) ⇒ Environment
Returns a new instance of Environment.
4 5 6 7 |
# File 'lib/kbt/environment.rb', line 4 def initialize(template, overrides = {}) @template = template @overrides = overrides end |
Instance Attribute Details
#overrides ⇒ Object (readonly)
Returns the value of attribute overrides.
3 4 5 |
# File 'lib/kbt/environment.rb', line 3 def overrides @overrides end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
3 4 5 |
# File 'lib/kbt/environment.rb', line 3 def template @template end |
Instance Method Details
#format_overrides ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/kbt/environment.rb', line 19 def format_overrides overrides.map do |k, v| [{ name: k.to_s, value: v.to_s }] end end |
#override_keys ⇒ Object
15 16 17 |
# File 'lib/kbt/environment.rb', line 15 def override_keys overrides.keys.map(&:to_s) end |
#to_h ⇒ Object
9 10 11 12 13 |
# File 'lib/kbt/environment.rb', line 9 def to_h template.value .reject { |e| override_keys.include?(e["name"]) } .concat(format_overrides) end |