Sha256: 34cdd7c46622d2561576009964e39f38005c75af1b7c932b0ab09e5d556ca2a7

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module Buildkite
  module Builder
    class Group
      include Buildkite::Pipelines::Attributes

      attr_reader :label
      attr_reader :data

      attribute :depends_on, append: true
      attribute :key

      def self.to_sym
        name.split('::').last.downcase.to_sym
      end

      def initialize(label, context, &block)
        @label = label
        @data = Data.new
        @data.steps = StepCollection.new(context.data.steps.templates)
        @data.notify = []

        # Use `clone` to copy over dsl's extended extensions
        @dsl = context.dsl.clone
        # Override dsl context to current group
        @dsl.instance_variable_set(:@context, self)

        instance_eval(&block) if block_given?
        self
      end

      def to_h
        attributes = super
        { group: label }.merge(attributes).merge(data.to_definition)
      end

      def method_missing(method_name, *args, **kwargs, &_block)
        @dsl.public_send(method_name, *args, **kwargs, &_block)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buildkite-builder-3.9.0 lib/buildkite/builder/group.rb