Class: KubeDSL::ObjectFieldRes
- Inherits:
-
Object
- Object
- KubeDSL::ObjectFieldRes
show all
- Includes:
- StringHelpers
- Defined in:
- lib/kube-dsl/object_field_res.rb
Constant Summary
StringHelpers::RUBY_KEYWORDS
Instance Attribute Summary collapse
Instance Method Summary
collapse
#capitalize, #underscore, #unkeywordify
Constructor Details
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
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
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
|