Class: KubeDSL::KeyValueFields
- Inherits:
-
Object
- Object
- KubeDSL::KeyValueFields
- Defined in:
- lib/kube-dsl/key_value_fields.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#kv_pairs ⇒ Object
readonly
Returns the value of attribute kv_pairs.
Instance Method Summary collapse
- #add(key, value) ⇒ Object
- #get(key) ⇒ Object
-
#initialize(format: :string) ⇒ KeyValueFields
constructor
A new instance of KeyValueFields.
- #merge!(other) ⇒ Object
- #remove(key) ⇒ Object
- #serialize ⇒ Object
- #set(key, value) ⇒ Object
Constructor Details
#initialize(format: :string) ⇒ KeyValueFields
Returns a new instance of KeyValueFields.
7 8 9 10 |
# File 'lib/kube-dsl/key_value_fields.rb', line 7 def initialize(format: :string) @format = format @kv_pairs = {} end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
5 6 7 |
# File 'lib/kube-dsl/key_value_fields.rb', line 5 def format @format end |
#kv_pairs ⇒ Object (readonly)
Returns the value of attribute kv_pairs.
5 6 7 |
# File 'lib/kube-dsl/key_value_fields.rb', line 5 def kv_pairs @kv_pairs end |
Instance Method Details
#add(key, value) ⇒ Object
12 13 14 |
# File 'lib/kube-dsl/key_value_fields.rb', line 12 def add(key, value) @kv_pairs[key] = value end |
#get(key) ⇒ Object
20 21 22 |
# File 'lib/kube-dsl/key_value_fields.rb', line 20 def get(key) @kv_pairs[key] end |
#merge!(other) ⇒ Object
34 35 36 |
# File 'lib/kube-dsl/key_value_fields.rb', line 34 def merge!(other) @kv_pairs.merge!(other.instance_variable_get(:@kv_pairs)) end |
#remove(key) ⇒ Object
16 17 18 |
# File 'lib/kube-dsl/key_value_fields.rb', line 16 def remove(key) @kv_pairs.delete(key) end |
#serialize ⇒ Object
28 29 30 31 32 |
# File 'lib/kube-dsl/key_value_fields.rb', line 28 def serialize @kv_pairs.each_with_object({}) do |(key, value), ret| ret[key] = serialize_value(value) end end |
#set(key, value) ⇒ Object
24 25 26 |
# File 'lib/kube-dsl/key_value_fields.rb', line 24 def set(key, value) @kv_pairs[key] = value end |