Class: KubeDSL::ResourceMeta
- Inherits:
-
Object
- Object
- KubeDSL::ResourceMeta
- Includes:
- StringHelpers
- Defined in:
- lib/kube-dsl/resource_meta.rb
Constant Summary
Constants included from StringHelpers
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#inflector ⇒ Object
readonly
Returns the value of attribute inflector.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #external? ⇒ Boolean
-
#initialize(ref, inflector) ⇒ ResourceMeta
constructor
A new instance of ResourceMeta.
- #to_ruby ⇒ Object
Methods included from StringHelpers
#capitalize, #underscore, #unkeywordify
Constructor Details
#initialize(ref, inflector) ⇒ ResourceMeta
Returns a new instance of ResourceMeta.
7 8 9 10 11 |
# File 'lib/kube-dsl/resource_meta.rb', line 7 def initialize(ref, inflector) @ref = ref @inflector = inflector @fields = {} end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
5 6 7 |
# File 'lib/kube-dsl/resource_meta.rb', line 5 def fields @fields end |
#inflector ⇒ Object (readonly)
Returns the value of attribute inflector.
5 6 7 |
# File 'lib/kube-dsl/resource_meta.rb', line 5 def inflector @inflector end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
5 6 7 |
# File 'lib/kube-dsl/resource_meta.rb', line 5 def ref @ref end |
Instance Method Details
#empty? ⇒ Boolean
17 18 19 |
# File 'lib/kube-dsl/resource_meta.rb', line 17 def empty? fields.size.zero? end |
#external? ⇒ Boolean
13 14 15 |
# File 'lib/kube-dsl/resource_meta.rb', line 13 def external? false end |
#to_ruby ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/kube-dsl/resource_meta.rb', line 21 def to_ruby ''.tap do |str| str << "module #{ref.ruby_namespace.join('::')}\n" str << " class #{ref.kind} < ::KubeDSL::DSLObject\n" str << fields_to_ruby str << "\n" str << validations str << "\n" str << serialize_method str << "\n" str << " def kind_sym\n" str << " :#{underscore(ref.kind)}\n" str << " end\n" str << " end\n" str << "end\n" end end |