Sha256: 6a8b91c7b636302921bd9e9b6a92f74c56272071433027e023fac8aeeb04cbf5

Contents?: true

Size: 1.35 KB

Versions: 924

Compression:

Stored size: 1.35 KB

Contents

module Aws
  module Partitions
    # @api private
    class PartitionList

      include Enumerable

      def initialize
        @partitions = {}
      end

      def clear
        @partitions = {}
      end

      # @return [Enumerator<Partition>]
      def each(&block)
        @partitions.each_value(&block)
      end

      # @param [String] partition_name
      # @return [Partition]
      def partition(partition_name)
        if @partitions.key?(partition_name)
          @partitions[partition_name]
        else
          msg = "invalid partition name #{partition_name.inspect}; valid "
          msg << "partition names include %s" % [@partitions.keys.join(', ')]
          raise ArgumentError, msg
        end
      end

      # @return [Array<Partition>]
      def partitions
        @partitions.values
      end

      # @param [Partition] partition
      def add_partition(partition)
        if Partition === partition
          @partitions[partition.name] = partition
        else
          raise ArgumentError, "expected Partition, got #{partition.class}"
        end
      end

      class << self

        # @api private
        def build(partitions)
          partitions['partitions'].inject(PartitionList.new) do |list, partition|
            list.add_partition(Partition.build(partition))
            list
          end
        end

      end
    end
  end
end

Version data entries

924 entries across 924 versions & 2 rubygems

Version Path
aws-sdk-core-2.11.632 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.631 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.630 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.629 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.628 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.627 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.626 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.625 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.624 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.623 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.622 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.621 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.620 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.619 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.618 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.617 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.616 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.615 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.614 lib/aws-sdk-core/partitions/partition_list.rb
aws-sdk-core-2.11.613 lib/aws-sdk-core/partitions/partition_list.rb