Class: Fried::Typings::StrictlyOneOf

Inherits:
Object
  • Object
show all
Includes:
MetaType, Type
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

Methods included from Type

#<=>, #call, included

Methods included from MetaType

included

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

Returns:



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