Class: Fried::Typings::OneOf
- Inherits:
-
Object
- Object
- Fried::Typings::OneOf
- Defined in:
- lib/fried/typings/one_of.rb
Overview
Checks if the object #is_a? object of the passed types
Instance Method Summary collapse
-
#initialize(*types) ⇒ OneOf
constructor
A new instance of OneOf.
- #valid?(obj) ⇒ Boolean
Methods included from Type
Methods included from MetaType
Constructor Details
#initialize(*types) ⇒ OneOf
18 19 20 |
# File 'lib/fried/typings/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/one_of.rb', line 22 def valid?(obj) types.any? do |type| Is[type].valid?(obj) end end |