Module: Concurrent::Actor::TypeCheck
- Included in:
- AbstractContext, ActorTerminated, Behaviour::Abstract, Core, Envelope, Reference, UnknownMessage
- Defined in:
- lib/concurrent-ruby-edge/concurrent/actor/type_check.rb
Overview
taken from Algebrick supplies type-checking helpers whenever included
Instance Method Summary collapse
- #Child!(value, *types) ⇒ undocumented
- #Child?(value, *types) ⇒ Boolean
- #Match!(value, *types) ⇒ undocumented
- #Match?(value, *types) ⇒ Boolean
- #Type!(value, *types) ⇒ undocumented
- #Type?(value, *types) ⇒ Boolean
Instance Method Details
#Child!(value, *types) ⇒ undocumented
33 34 35 36 37 |
# File 'lib/concurrent-ruby-edge/concurrent/actor/type_check.rb', line 33 def Child!(value, *types) Child?(value, *types) or TypeCheck.error(value, 'is not child', types) value end |
#Child?(value, *types) ⇒ Boolean
28 29 30 31 |
# File 'lib/concurrent-ruby-edge/concurrent/actor/type_check.rb', line 28 def Child?(value, *types) Type?(value, Class) && types.any? { |t| value <= t } end |
#Match!(value, *types) ⇒ undocumented
22 23 24 25 26 |
# File 'lib/concurrent-ruby-edge/concurrent/actor/type_check.rb', line 22 def Match!(value, *types) Match?(value, *types) or TypeCheck.error(value, 'is not matching', types) value end |
#Match?(value, *types) ⇒ Boolean
18 19 20 |
# File 'lib/concurrent-ruby-edge/concurrent/actor/type_check.rb', line 18 def Match?(value, *types) types.any? { |t| t === value } end |
#Type!(value, *types) ⇒ undocumented
12 13 14 15 16 |
# File 'lib/concurrent-ruby-edge/concurrent/actor/type_check.rb', line 12 def Type!(value, *types) Type?(value, *types) or TypeCheck.error(value, 'is not', types) value end |
#Type?(value, *types) ⇒ Boolean
8 9 10 |
# File 'lib/concurrent-ruby-edge/concurrent/actor/type_check.rb', line 8 def Type?(value, *types) types.any? { |t| value.is_a? t } end |