Class: KubeDSL::KeyValueFields

Inherits:
Object
  • Object
show all
Defined in:
lib/kube-dsl/key_value_fields.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#formatObject (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_pairsObject (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

#serializeObject



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