Class: Fried::Typings::StrictlyOneOf
- Inherits:
-
Object
- Object
- Fried::Typings::StrictlyOneOf
- Defined in:
- lib/fried/typings/strictly_one_of.rb
Overview
Checks if the object.class is exactly one of the passed types
Instance Method Summary collapse
-
#initialize(*types) ⇒ StrictlyOneOf
constructor
A new instance of StrictlyOneOf.
- #valid?(obj) ⇒ Boolean
Methods included from Type
Methods included from MetaType
Constructor Details
#initialize(*types) ⇒ StrictlyOneOf
Returns a new instance of StrictlyOneOf.
18 19 20 |
# File 'lib/fried/typings/strictly_one_of.rb', line 18 def initialize(*types) @types = types end |
Instance Method Details
#valid?(obj) ⇒ Boolean
22 23 24 25 26 |
# File 'lib/fried/typings/strictly_one_of.rb', line 22 def valid?(obj) types.any? do |type| IsStrictly[type].valid?(obj) end end |