Class: KubeDSL::FieldRes
- Inherits:
-
Object
- Object
- KubeDSL::FieldRes
- Includes:
- RbiHelpers, StringHelpers
- Defined in:
- lib/kube-dsl/field_res.rb
Constant Summary
Constants included from RbiHelpers
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.
-
#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, type, required) ⇒ FieldRes
constructor
A new instance of FieldRes.
- #serialize_call(_inflector) ⇒ Object
- #validations(_inflector) ⇒ Object
Methods included from RbiHelpers
Methods included from StringHelpers
#capitalize, #underscore, #unkeywordify
Constructor Details
#initialize(name, type, required) ⇒ FieldRes
Returns a new instance of FieldRes.
11 12 13 14 15 |
# File 'lib/kube-dsl/field_res.rb', line 11 def initialize(name, type, required) @name = name @type = type @required = required end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/kube-dsl/field_res.rb', line 7 def name @name end |
#required ⇒ Object (readonly) Also known as: required?
Returns the value of attribute required.
7 8 9 |
# File 'lib/kube-dsl/field_res.rb', line 7 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/kube-dsl/field_res.rb', line 7 def type @type end |
Instance Method Details
#fields_to_rbi(inflector) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/kube-dsl/field_res.rb', line 21 def fields_to_rbi(inflector) [ "T::Sig::WithoutRuntime.sig { params(val: T.nilable(#{rbi_type_for(@type)})).returns(T.nilable(#{rbi_type_for(@type)})) }", "def #{ruby_safe_name}(val = nil); end" ] end |
#fields_to_ruby(_inflector) ⇒ Object
17 18 19 |
# File 'lib/kube-dsl/field_res.rb', line 17 def fields_to_ruby(_inflector) ["value_field :#{ruby_safe_name}"] end |
#serialize_call(_inflector) ⇒ Object
34 35 36 |
# File 'lib/kube-dsl/field_res.rb', line 34 def serialize_call(_inflector) ruby_safe_name end |
#validations(_inflector) ⇒ Object
28 29 30 31 32 |
# File 'lib/kube-dsl/field_res.rb', line 28 def validations(_inflector) [].tap do |result| result << "validates :#{ruby_safe_name}, field: { format: :#{type} }, presence: #{required? ? 'true' : 'false'}" end end |