mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 22:36:50 +00:00
26 lines
374 B
Ruby
26 lines
374 B
Ruby
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
|