Sha256: d55d946bdbd83e5173ecca23a3699e5b61d816691cd6ec847a9aec1da13cca87

Contents?: true

Size: 499 Bytes

Versions: 16

Compression:

Stored size: 499 Bytes

Contents

# 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...

class ArraySet < Array
	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
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
json-schema-openc-fork-0.0.2 lib/json-schema/util/array_set.rb
json-schema-openc-fork-0.0.1 lib/json-schema/util/array_set.rb
json-schema-2.5.0 lib/json-schema/util/array_set.rb
json-schema-2.4.1 lib/json-schema/util/array_set.rb
json-schema-2.4.0 lib/json-schema/util/array_set.rb
json-schema-2.3.0 lib/json-schema/util/array_set.rb
json-schema-2.2.5 lib/json-schema/util/array_set.rb
json-schema-pvdgm-2.3.1 lib/json-schema/util/array_set.rb
json-schema-2.2.4 lib/json-schema/util/array_set.rb
json-schema-2.2.3 lib/json-schema/util/array_set.rb
json-schema-2.2.2 lib/json-schema/util/array_set.rb
json-schema-2.2.1 lib/json-schema/util/array_set.rb
json-schema-2.2.0 lib/json-schema/util/array_set.rb
json-schema-2.1.9 lib/json-schema/util/array_set.rb
json-schema-2.1.8 lib/json-schema/util/array_set.rb
json-schema-2.1.7 lib/json-schema/util/array_set.rb