Class: ArraySet

Inherits:
Array
  • Object
show all
Defined in:
lib/json-schema/util/array_set.rb

Overview

This is a hack that I don't want to ever use anywhere else or repeat EVER, but we need enums to be an Array to pass schema validation. But we also want fast lookup! And we can't use sets because of backport support… so…

Instance Method Summary collapse

Instance Method Details

#include?(obj) ⇒ Boolean

Returns:

  • (Boolean)

6
7
8
9
10
11
12
13
# File 'lib/json-schema/util/array_set.rb', line 6

def include?(obj)
	# On first invocation create a HASH (yeah, yeah) to act as our set given the array values
	if !defined? @array_values
		@array_values = {}
		self.each {|x| @array_values[x] = 1}
	end
	@array_values.has_key? obj
end