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.



415
416
417
418
# File 'lib/primalize/single.rb', line 415

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

Instance Method Details

#===(value) ⇒ Object



420
421
422
# File 'lib/primalize/single.rb', line 420

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

#inspectObject



424
425
426
# File 'lib/primalize/single.rb', line 424

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