Sha256: 82487dd3088eb7480c48dc3825a5ede84c1de0907ce121a1a1b4af8d8241617f
Contents?: true
Size: 1.17 KB
Versions: 8
Compression:
Stored size: 1.17 KB
Contents
class KuberKit::Core::ServiceDefinition attr_reader :service_name, :template_name Contract Or[Symbol, String] => Any def initialize(service_name) @service_name = service_name.to_sym end 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), deploy_strategy: get_value(@deploy_strategy), ) end def template(value = nil, &block) @template_name = block_given? ? block : value self end def tags(*value, &block) @tags = block_given? ? block : Array(value).flatten self end def images(*value, &block) @images = block_given? ? block : Array(value).flatten self end def attributes(value = nil, &block) @attributes = block_given? ? block : value self end def deploy_strategy(value = nil, &block) @deploy_strategy = block_given? ? block : value self end private def get_value(variable) variable.is_a?(Proc) ? variable.call : variable end end
Version data entries
8 entries across 8 versions & 1 rubygems