Class: KubeDSL::ResourceMeta
- Inherits:
-
Object
- Object
- KubeDSL::ResourceMeta
- Includes:
- StringHelpers
- Defined in:
- lib/kube-dsl/resource_meta.rb
Instance Attribute Summary collapse
-
#array_fields ⇒ Object
readonly
Returns the value of attribute array_fields.
-
#default_fields ⇒ Object
readonly
Returns the value of attribute default_fields.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#inflector ⇒ Object
readonly
Returns the value of attribute inflector.
-
#key_value_fields ⇒ Object
readonly
Returns the value of attribute key_value_fields.
-
#object_fields ⇒ Object
readonly
Returns the value of attribute object_fields.
-
#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
Constructor Details
#initialize(ref, inflector) ⇒ ResourceMeta
Returns a new instance of ResourceMeta.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/kube-dsl/resource_meta.rb', line 9 def initialize(ref, inflector) @ref = ref @inflector = inflector @fields = [] @key_value_fields = {} @array_fields = {} @object_fields = {} @default_fields = {} end |
Instance Attribute Details
#array_fields ⇒ Object (readonly)
Returns the value of attribute array_fields.
6 7 8 |
# File 'lib/kube-dsl/resource_meta.rb', line 6 def array_fields @array_fields end |
#default_fields ⇒ Object (readonly)
Returns the value of attribute default_fields.
7 8 9 |
# File 'lib/kube-dsl/resource_meta.rb', line 7 def default_fields @default_fields end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
6 7 8 |
# File 'lib/kube-dsl/resource_meta.rb', line 6 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 |
#key_value_fields ⇒ Object (readonly)
Returns the value of attribute key_value_fields.
6 7 8 |
# File 'lib/kube-dsl/resource_meta.rb', line 6 def key_value_fields @key_value_fields end |
#object_fields ⇒ Object (readonly)
Returns the value of attribute object_fields.
6 7 8 |
# File 'lib/kube-dsl/resource_meta.rb', line 6 def object_fields @object_fields 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
24 25 26 27 28 29 30 31 32 |
# File 'lib/kube-dsl/resource_meta.rb', line 24 def empty? field_count = fields.size + key_value_fields.size + array_fields.size + object_fields.size + default_fields.size field_count.zero? end |
#external? ⇒ Boolean
20 21 22 |
# File 'lib/kube-dsl/resource_meta.rb', line 20 def external? false end |
#to_ruby ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/kube-dsl/resource_meta.rb', line 34 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 << 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 |