Class: Fried::Typings::IsStrictly

Inherits:
Object
  • Object
show all
Includes:
MetaType, Type
Defined in:
lib/fried/typings/is_strictly.rb

Overview

Checks if the object.class is exactly of the passed type

Instance Method Summary collapse

Methods included from Type

#<=>, #call, included

Methods included from MetaType

included

Constructor Details

#initialize(type) ⇒ IsStrictly

Returns a new instance of IsStrictly.



17
18
19
# File 'lib/fried/typings/is_strictly.rb', line 17

def initialize(type)
  @type = type
end

Instance Method Details

#valid?(obj) ⇒ Boolean

Returns:



21
22
23
24
25
# File 'lib/fried/typings/is_strictly.rb', line 21

def valid?(obj)
  return type.valid?(obj) if type < Type

  obj.class == type
end