Class: Hashape::Specifiers::OneOf

Inherits:
Specifier
  • Object
show all
Defined in:
lib/hashape.rb

Overview

Given a list of type specs, allows the value to match any one of those type specs.

Instance Attribute Summary

Attributes inherited from Specifier

#spec

Instance Method Summary collapse

Methods inherited from Specifier

[], #initialize

Constructor Details

This class inherits a constructor from Hashape::Specifiers::Specifier

Instance Method Details

#===(v) ⇒ Object



46
47
48
49
# File 'lib/hashape.rb', line 46

def ===(v)
  raise 'spec for OneOf must be an array' unless self.spec.is_a?(Array)
  self.spec.any? { |s| s === v }
end