Sha256: 92fcdd27c4be7be81cc8f39f2f7ea738bdcf3dca5df39fc112211c4b5edcf26f

Contents?: true

Size: 374 Bytes

Versions: 1

Compression:

Stored size: 374 Bytes

Contents

module ActiveModel
  class OrderedSet
    def initialize(array)
      @array = array
      @hash = {}

      array.each do |item|
        @hash[item] = true
      end
    end

    def merge!(other)
      other.each do |item|
        next if @hash.key?(item)

        @hash[item] = true
        @array.push item
      end
    end

    def to_a
      @array
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_model_serializers-0.6.0 lib/active_model/ordered_set.rb