Sha256: c654daa80321405c5fe1610da80d41d2109800e35cf67dfcbeb0e9ce7a577c6a

Contents?: true

Size: 883 Bytes

Versions: 2

Compression:

Stored size: 883 Bytes

Contents

require "stepmod/utils/change_edition"

module Stepmod
  module Utils
    class ChangeEditionCollection
      def initialize
        @collection = {}
      end

      def fetch_or_initialize(version)
        @collection[version] ||=
          Stepmod::Utils::ChangeEdition.new("version" => version)
      end

      def to_h
        @collection.values.map(&:to_h)
      end

      def []=(version, change_edition)
        klass = Stepmod::Utils::ChangeEdition
        @collection[version] = if change_edition.is_a?(klass)
                                 change_edition
                               else
                                 klass.new(change_edition)
                               end
      end

      def [](version)
        @collection[version]
      end

      def count
        @collection.values.count
      end
      alias_method :size, :count
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stepmod-utils-0.6.7 lib/stepmod/utils/change_edition_collection.rb
stepmod-utils-0.6.6 lib/stepmod/utils/change_edition_collection.rb