Class: KubeDSL::FieldRes
- Inherits:
-
Object
- Object
- KubeDSL::FieldRes
- Includes:
- StringHelpers
- Defined in:
- lib/kube-dsl/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.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #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 StringHelpers
#capitalize, #underscore, #unkeywordify
Constructor Details
#initialize(name, type, required) ⇒ FieldRes
Returns a new instance of FieldRes.
9 10 11 12 13 |
# File 'lib/kube-dsl/field_res.rb', line 9 def initialize(name, type, required) @name = name @type = type @required = required end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/kube-dsl/field_res.rb', line 5 def name @name end |
#required ⇒ Object (readonly) Also known as: required?
Returns the value of attribute required.
5 6 7 |
# File 'lib/kube-dsl/field_res.rb', line 5 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/kube-dsl/field_res.rb', line 5 def type @type end |
Instance Method Details
#fields_to_ruby(_inflector) ⇒ Object
15 16 17 |
# File 'lib/kube-dsl/field_res.rb', line 15 def fields_to_ruby(_inflector) ["value_field :#{ruby_safe_name}"] end |
#serialize_call(_inflector) ⇒ Object
25 26 27 |
# File 'lib/kube-dsl/field_res.rb', line 25 def serialize_call(_inflector) ruby_safe_name end |
#validations(_inflector) ⇒ Object
19 20 21 22 23 |
# File 'lib/kube-dsl/field_res.rb', line 19 def validations(_inflector) [].tap do |result| result << "validates :#{ruby_safe_name}, field: { format: :#{type} }, presence: #{required? ? 'true' : 'false'}" end end |