Class: KubeDSL::KeyValueFieldRes
- Inherits:
-
Object
- Object
- KubeDSL::KeyValueFieldRes
- Includes:
- StringHelpers
- Defined in:
- lib/kube-dsl/key_value_field_res.rb
Constant Summary
Constants included from StringHelpers
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required ⇒ Object
(also: #required?)
readonly
Returns the value of attribute required.
-
#res ⇒ Object
readonly
Returns the value of attribute res.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #fields_to_rbi(_inflector) ⇒ Object
- #fields_to_ruby(_inflector) ⇒ Object
-
#initialize(name, res, type, required) ⇒ KeyValueFieldRes
constructor
A new instance of KeyValueFieldRes.
- #serialize_call(_inflector) ⇒ Object
- #validations(_inflector) ⇒ Object
Methods included from StringHelpers
#capitalize, #underscore, #unkeywordify
Constructor Details
#initialize(name, res, type, required) ⇒ KeyValueFieldRes
Returns a new instance of KeyValueFieldRes.
10 11 12 13 14 15 |
# File 'lib/kube-dsl/key_value_field_res.rb', line 10 def initialize(name, res, type, required) @name = name @res = res @type = type @required = required end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/kube-dsl/key_value_field_res.rb', line 6 def name @name end |
#required ⇒ Object (readonly) Also known as: required?
Returns the value of attribute required.
6 7 8 |
# File 'lib/kube-dsl/key_value_field_res.rb', line 6 def required @required end |
#res ⇒ Object (readonly)
Returns the value of attribute res.
6 7 8 |
# File 'lib/kube-dsl/key_value_field_res.rb', line 6 def res @res end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/kube-dsl/key_value_field_res.rb', line 6 def type @type end |
Instance Method Details
#fields_to_rbi(_inflector) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/kube-dsl/key_value_field_res.rb', line 23 def fields_to_rbi(_inflector) [ "T::Sig::WithoutRuntime.sig { params(block: T.nilable(T.proc.void)).returns(::KubeDSL::KeyValueFields) }", "def #{underscore(name)}(&block); end" ] end |
#fields_to_ruby(_inflector) ⇒ Object
17 18 19 20 21 |
# File 'lib/kube-dsl/key_value_field_res.rb', line 17 def fields_to_ruby(_inflector) [ "key_value_field(:#{underscore(name)}, format: :#{type})" ] end |
#serialize_call(_inflector) ⇒ Object
36 37 38 |
# File 'lib/kube-dsl/key_value_field_res.rb', line 36 def serialize_call(_inflector) "#{underscore(name)}.serialize" end |
#validations(_inflector) ⇒ Object
30 31 32 33 34 |
# File 'lib/kube-dsl/key_value_field_res.rb', line 30 def validations(_inflector) [].tap do |result| result << "validates :#{underscore(name)}, kv: { value_format: :#{type} }, presence: #{required? ? 'true' : 'false'}" end end |