Class: KubeDSL::KeyValueFields
- Inherits:
-
Object
- Object
- KubeDSL::KeyValueFields
- Defined in:
- lib/kube-dsl/key_value_fields.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns(Symbol) }.
-
#kv_pairs ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns(T::Hash[Symbol, String]) }.
Instance Method Summary collapse
-
#add(key, value) ⇒ Object
T::Sig::WithoutRuntime.sig { params(key: Symbol, value: String).void }.
-
#get(key) ⇒ Object
T::Sig::WithoutRuntime.sig { params(key: Symbol).returns(T.nilable(String)) }.
-
#initialize(format: :string) ⇒ KeyValueFields
constructor
T::Sig::WithoutRuntime.sig { params(format: Symbol).void }.
-
#merge!(other) ⇒ Object
T::Sig::WithoutRuntime.sig { params(other: KubeDSL::KeyValueFields).void }.
-
#remove(key) ⇒ Object
T::Sig::WithoutRuntime.sig { params(key: Symbol).void }.
-
#serialize ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T::Hash[Symbol, String]) }.
-
#set(key, value) ⇒ Object
T::Sig::WithoutRuntime.sig { params(key: Symbol, value: String).void }.
Constructor Details
#initialize(format: :string) ⇒ KeyValueFields
T::Sig::WithoutRuntime.sig { params(format: Symbol).void }
16 17 18 19 |
# File 'lib/kube-dsl/key_value_fields.rb', line 16 def initialize(format: :string) @format = format @kv_pairs = {} end |
Instance Attribute Details
#format ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns(Symbol) }
10 11 12 |
# File 'lib/kube-dsl/key_value_fields.rb', line 10 def format @format end |
#kv_pairs ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns(T::Hash[Symbol, String]) }
13 14 15 |
# File 'lib/kube-dsl/key_value_fields.rb', line 13 def kv_pairs @kv_pairs end |
Instance Method Details
#add(key, value) ⇒ Object
T::Sig::WithoutRuntime.sig { params(key: Symbol, value: String).void }
22 23 24 |
# File 'lib/kube-dsl/key_value_fields.rb', line 22 def add(key, value) @kv_pairs[key] = value end |
#get(key) ⇒ Object
T::Sig::WithoutRuntime.sig { params(key: Symbol).returns(T.nilable(String)) }
32 33 34 |
# File 'lib/kube-dsl/key_value_fields.rb', line 32 def get(key) @kv_pairs[key] end |
#merge!(other) ⇒ Object
T::Sig::WithoutRuntime.sig { params(other: KubeDSL::KeyValueFields).void }
49 50 51 |
# File 'lib/kube-dsl/key_value_fields.rb', line 49 def merge!(other) @kv_pairs.merge!(other.instance_variable_get(:@kv_pairs)) end |
#remove(key) ⇒ Object
T::Sig::WithoutRuntime.sig { params(key: Symbol).void }
27 28 29 |
# File 'lib/kube-dsl/key_value_fields.rb', line 27 def remove(key) @kv_pairs.delete(key) end |
#serialize ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T::Hash[Symbol, String]) }
42 43 44 45 46 |
# File 'lib/kube-dsl/key_value_fields.rb', line 42 def serialize @kv_pairs.each_with_object({}) do |(key, value), ret| ret[key] = serialize_value(value) end end |
#set(key, value) ⇒ Object
T::Sig::WithoutRuntime.sig { params(key: Symbol, value: String).void }
37 38 39 |
# File 'lib/kube-dsl/key_value_fields.rb', line 37 def set(key, value) @kv_pairs[key] = value end |