Module: Concurrent::Actor::TypeCheck

Included in:
AbstractContext, ActorTerminated, Behaviour::Abstract, Core, Envelope, Reference, UnknownMessage
Defined in:
lib/concurrent/actor/type_check.rb

Overview

taken from Algebrick supplies type-checking helpers whenever included

Instance Method Summary (collapse)

Instance Method Details

- (undocumented) Child!(value, *types)



33
34
35
36
37
# File 'lib/concurrent/actor/type_check.rb', line 33

def Child!(value, *types)
  Child?(value, *types) or
      TypeCheck.error(value, 'is not child', types)
  value
end

- (Boolean) Child?(value, *types)

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/concurrent/actor/type_check.rb', line 28

def Child?(value, *types)
  Type?(value, Class) &&
      types.any? { |t| value <= t }
end

- (undocumented) Match!(value, *types)



22
23
24
25
26
# File 'lib/concurrent/actor/type_check.rb', line 22

def Match!(value, *types)
  Match?(value, *types) or
      TypeCheck.error(value, 'is not matching', types)
  value
end

- (Boolean) Match?(value, *types)

Returns:

  • (Boolean)


18
19
20
# File 'lib/concurrent/actor/type_check.rb', line 18

def Match?(value, *types)
  types.any? { |t| t === value }
end

- (undocumented) Type!(value, *types)



12
13
14
15
16
# File 'lib/concurrent/actor/type_check.rb', line 12

def Type!(value, *types)
  Type?(value, *types) or
      TypeCheck.error(value, 'is not', types)
  value
end

- (Boolean) Type?(value, *types)

Returns:

  • (Boolean)


8
9
10
# File 'lib/concurrent/actor/type_check.rb', line 8

def Type?(value, *types)
  types.any? { |t| value.is_a? t }
end