move OrderedSet to separate file

This commit is contained in:
Tee Parham 2012-09-15 09:34:11 -07:00 committed by Jo Liss
parent b8f01ba2f3
commit 9584b9e147
3 changed files with 26 additions and 24 deletions

View File

@ -0,0 +1,25 @@
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

View File

@ -3,30 +3,6 @@ require "active_support/core_ext/module/anonymous"
require "set"
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
# Active Model Serializer
#
# Provides a basic serializer implementation that allows you to easily

View File

@ -2,6 +2,7 @@ require "active_support"
require "active_support/core_ext/string/inflections"
require "active_support/notifications"
require "active_model"
require "active_model/ordered_set"
require "active_model/array_serializer"
require "active_model/serializer"
require "set"