Class: KuberKit::Core::ServiceDefinition
- Defined in:
- lib/kuber_kit/core/service_definition.rb
Instance Attribute Summary collapse
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
-
#template_name ⇒ Object
readonly
Returns the value of attribute template_name.
Instance Method Summary collapse
- #attributes(value = nil, &block) ⇒ Object
- #images(*value, &block) ⇒ Object
-
#initialize(service_name) ⇒ ServiceDefinition
constructor
A new instance of ServiceDefinition.
- #tags(*value, &block) ⇒ Object
- #template(value = nil, &block) ⇒ Object
- #to_service_attrs ⇒ Object
Constructor Details
#initialize(service_name) ⇒ ServiceDefinition
Returns a new instance of ServiceDefinition.
5 6 7 |
# File 'lib/kuber_kit/core/service_definition.rb', line 5 def initialize(service_name) @service_name = service_name.to_sym end |
Instance Attribute Details
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
2 3 4 |
# File 'lib/kuber_kit/core/service_definition.rb', line 2 def service_name @service_name end |
#template_name ⇒ Object (readonly)
Returns the value of attribute template_name.
2 3 4 |
# File 'lib/kuber_kit/core/service_definition.rb', line 2 def template_name @template_name end |
Instance Method Details
#attributes(value = nil, &block) ⇒ Object
37 38 39 40 41 |
# File 'lib/kuber_kit/core/service_definition.rb', line 37 def attributes(value = nil, &block) @attributes = block_given? ? block : value self end |
#images(*value, &block) ⇒ Object
31 32 33 34 35 |
# File 'lib/kuber_kit/core/service_definition.rb', line 31 def images(*value, &block) @images = block_given? ? block : Array(value).flatten self end |
#tags(*value, &block) ⇒ Object
25 26 27 28 29 |
# File 'lib/kuber_kit/core/service_definition.rb', line 25 def (*value, &block) @tags = block_given? ? block : Array(value).flatten self end |
#template(value = nil, &block) ⇒ Object
19 20 21 22 23 |
# File 'lib/kuber_kit/core/service_definition.rb', line 19 def template(value = nil, &block) @template_name = block_given? ? block : value self end |
#to_service_attrs ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/kuber_kit/core/service_definition.rb', line 9 def to_service_attrs OpenStruct.new( name: @service_name, template_name: get_value(@template_name), tags: Array(get_value(@tags)).map(&:to_sym), images: Array(get_value(@images)).map(&:to_sym), attributes: get_value(@attributes), ) end |