Class: JsonStructure::AnyOf

Inherits:
Type
  • Object
show all
Defined in:
lib/json_structure/any_of.rb

Instance Method Summary collapse

Constructor Details

#initialize(*types) ⇒ AnyOf

Returns a new instance of AnyOf.



3
4
5
# File 'lib/json_structure/any_of.rb', line 3

def initialize(*types)
  @types = types
end

Instance Method Details

#===(value) ⇒ Object



7
8
9
# File 'lib/json_structure/any_of.rb', line 7

def ===(value)
  @types.any? { |type| type === value }
end

#|(type) ⇒ Object



11
12
13
# File 'lib/json_structure/any_of.rb', line 11

def |(type)
  AnyOf.new(*(@types + [type]))
end