Class: Primalize::Single::All

Inherits:
Object
  • Object
show all
Includes:
Type
Defined in:
lib/primalize/single.rb

Constant Summary

Constants included from Type

Type::DEFAULT_COERCION

Instance Method Summary collapse

Methods included from Type

#coerce

Constructor Details

#initialize(types, &coercion) ⇒ All

Returns a new instance of All.



433
434
435
436
# File 'lib/primalize/single.rb', line 433

def initialize types, &coercion
  @types = types
  @coercion = coercion
end

Instance Method Details

#===(value) ⇒ Object



438
439
440
# File 'lib/primalize/single.rb', line 438

def === value
  @types.all? { |type| type === value }
end

#inspectObject



442
443
444
# File 'lib/primalize/single.rb', line 442

def inspect
  "all(#{@types.map(&:inspect).join(', ')})"
end