Class: Alf::Engine::TypeSafe

Inherits:
Object
  • Object
show all
Includes:
Cog
Defined in:
lib/alf/engine/type_safe.rb

Constant Summary

Constants included from Cog

Cog::EMPTY_CHILDREN, Cog::EMPTY_OPTIONS

Instance Attribute Summary collapse

Attributes included from Compiler::Cog

#compiler, #expr

Instance Method Summary collapse

Methods included from Cog

#arguments, #children, #each, #options, #to_s

Methods included from Compiler::Cog

#cog_orders, #orderedby?, #relation_type, #to_ascii_tree, #to_cog, #to_relation

Constructor Details

#initialize(operand, checker, expr = nil, compiler = nil) ⇒ TypeSafe

Creates an Coerce instance


13
14
15
16
17
# File 'lib/alf/engine/type_safe.rb', line 13

def initialize(operand, checker, expr = nil, compiler = nil)
  super(expr, compiler)
  @operand = operand
  @checker = checker
end

Instance Attribute Details

#checkerTypeChecker (readonly)


10
11
12
# File 'lib/alf/engine/type_safe.rb', line 10

def checker
  @checker
end

#operandEnumerable (readonly)


7
8
9
# File 'lib/alf/engine/type_safe.rb', line 7

def operand
  @operand
end

Instance Method Details

#_eachObject


20
21
22
23
24
25
# File 'lib/alf/engine/type_safe.rb', line 20

def _each
  @operand.each do |tuple|
    raise TypeCheckError, "Invalid tuple `#{tuple.inspect}`" unless checker===tuple
    yield(tuple)
  end
end