Sha256: c623004e15cf1c08ab4bd0952e4b1e614c1a5cf2307fa6764aab164bac7e6aa0

Contents?: true

Size: 926 Bytes

Versions: 7

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

module Capistrano
  module ASG
    module Rolling
      # Collection of Auto Scaling Groups.
      class AutoscaleGroups
        include Enumerable

        def initialize(groups = [])
          @groups = groups
        end

        def <<(group)
          @groups << group
        end

        def each(&block)
          @groups.reject { |group| filtered?(group) }.each(&block)
        end

        def launch_templates
          templates = @groups.map(&:launch_template)
          LaunchTemplates.new(templates)
        end

        def with_launch_template(launch_template)
          self.class.new(select { |group| group.launch_template == launch_template })
        end

        private

        def filtered?(group)
          return false if Configuration.auto_scaling_group_name.nil?

          Configuration.auto_scaling_group_name != group.name
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
capistrano-asg-rolling-0.5.1 lib/capistrano/asg/rolling/autoscale_groups.rb
capistrano-asg-rolling-0.5.0 lib/capistrano/asg/rolling/autoscale_groups.rb
capistrano-asg-rolling-0.4.1 lib/capistrano/asg/rolling/autoscale_groups.rb
capistrano-asg-rolling-0.4.0 lib/capistrano/asg/rolling/autoscale_groups.rb
capistrano-asg-rolling-0.3.0 lib/capistrano/asg/rolling/autoscale_groups.rb
capistrano-asg-rolling-0.2.1 lib/capistrano/asg/rolling/autoscale_groups.rb
capistrano-asg-rolling-0.2.0 lib/capistrano/asg/rolling/autoscale_groups.rb