Class: KubeDSL::ObjectFieldRes
- Inherits:
-
Object
- Object
- KubeDSL::ObjectFieldRes
- Includes:
- StringHelpers
- Defined in:
- lib/kube-dsl/object_field_res.rb
Constant Summary
Constants included from StringHelpers
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#res ⇒ Object
readonly
Returns the value of attribute res.
Instance Method Summary collapse
- #fields_to_rbi(_inflector) ⇒ Object
- #fields_to_ruby(_inflector) ⇒ Object
-
#initialize(name, res) ⇒ ObjectFieldRes
constructor
A new instance of ObjectFieldRes.
- #serialize_call(_inflector) ⇒ Object
- #validations(_inflector) ⇒ Object
Methods included from StringHelpers
#capitalize, #underscore, #unkeywordify
Constructor Details
#initialize(name, res) ⇒ ObjectFieldRes
Returns a new instance of ObjectFieldRes.
8 9 10 11 |
# File 'lib/kube-dsl/object_field_res.rb', line 8 def initialize(name, res) @name = name @res = res end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/kube-dsl/object_field_res.rb', line 6 def name @name end |
#res ⇒ Object (readonly)
Returns the value of attribute res.
6 7 8 |
# File 'lib/kube-dsl/object_field_res.rb', line 6 def res @res end |
Instance Method Details
#fields_to_rbi(_inflector) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/kube-dsl/object_field_res.rb', line 19 def fields_to_rbi(_inflector) [ "T::Sig::WithoutRuntime.sig { params(block: T.nilable(T.proc.bind(#{ruby_type}).void)).returns(#{ruby_type}) }", "def #{ruby_safe_name}(&block); end", "", "T::Sig::WithoutRuntime.sig { returns(T::Boolean) }", "def #{ruby_safe_name}_present?; end" ] end |
#fields_to_ruby(_inflector) ⇒ Object
13 14 15 16 17 |
# File 'lib/kube-dsl/object_field_res.rb', line 13 def fields_to_ruby(_inflector) [ "object_field(:#{ruby_safe_name}) { #{ruby_type}.new }" ] end |
#serialize_call(_inflector) ⇒ Object
36 37 38 |
# File 'lib/kube-dsl/object_field_res.rb', line 36 def serialize_call(_inflector) "#{ruby_safe_name}.serialize" end |
#validations(_inflector) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/kube-dsl/object_field_res.rb', line 29 def validations(_inflector) [].tap do |result| ruby_type = [*res.ref.ruby_namespace, res.ref.kind].join('::') result << "validates :#{ruby_safe_name}, object: { kind_of: #{ruby_type} }" end end |