Class: Alf::Update::Deleter

Inherits:
Algebra::Compiler show all
Defined in:
lib/alf/update/deleter.rb

Instance Method Summary collapse

Methods inherited from Algebra::Compiler

#apply, #call, #on_missing

Methods included from Algebra::Visitor

#copy_and_apply

Instance Method Details

#apply_and_split(expr, predicate, list) ⇒ Object

Reusable rules


13
14
15
16
17
18
19
20
# File 'lib/alf/update/deleter.rb', line 13

def apply_and_split(expr, predicate, list)
  top, down = predicate.and_split(list)
  if top.tautology?
    apply(expr.operand, predicate)
  else
    raise NotSupportedError
  end
end

#not_supported(expr, *args) ⇒ Object Also known as: on_coerce, on_compact, on_generator, on_join, on_matching, on_minus, not_matching, on_quota, on_summarize, on_ungroup, on_union, on_unwrap

overridings

Raises:


7
8
9
# File 'lib/alf/update/deleter.rb', line 7

def not_supported(expr, *args)
  raise NotSupportedError, "Unable to delete through `#{expr}`"
end

#on_autonum(expr, predicate) ⇒ Object

non relational


34
35
36
# File 'lib/alf/update/deleter.rb', line 34

def on_autonum(expr, predicate)
  apply_and_split(expr, predicate, AttrList[expr.as])
end

#on_defaults(expr, predicate) ⇒ Object


43
44
45
# File 'lib/alf/update/deleter.rb', line 43

def on_defaults(expr, predicate)
  apply_and_split(expr, predicate, expr.defaults.to_attr_list)
end

#on_extend(expr, predicate) ⇒ Object

relational


53
54
55
# File 'lib/alf/update/deleter.rb', line 53

def on_extend(expr, predicate)
  apply_and_split(expr, predicate, expr.ext.to_attr_list)
end

#on_group(expr, predicate) ⇒ Object


57
58
59
# File 'lib/alf/update/deleter.rb', line 57

def on_group(expr, predicate)
  apply_and_split(expr, predicate, AttrList[expr.as])
end

#on_intersect(expr, predicate) ⇒ Object


61
62
63
64
# File 'lib/alf/update/deleter.rb', line 61

def on_intersect(expr, predicate)
  apply(expr.left, predicate)
  apply(expr.right, predicate)
end

#on_leaf_operand(expr, predicate) ⇒ Object

leaf Operand, recursion end :-)


28
29
30
# File 'lib/alf/update/deleter.rb', line 28

def on_leaf_operand(expr, predicate)
  expr.to_relvar.delete(predicate)
end

#on_rank(expr, predicate) ⇒ Object


75
76
77
# File 'lib/alf/update/deleter.rb', line 75

def on_rank(expr, predicate)
  apply_and_split(expr, predicate, AttrList[expr.as])
end

#on_rename(expr, predicate) ⇒ Object


79
80
81
# File 'lib/alf/update/deleter.rb', line 79

def on_rename(expr, predicate)
  apply_and_split(expr, predicate, expr.renaming.invert.to_attr_list)
end

#on_restrict(expr, predicate) ⇒ Object


83
84
85
# File 'lib/alf/update/deleter.rb', line 83

def on_restrict(expr, predicate)
  apply(expr.operand, expr.predicate & predicate)
end

#on_unary_delegate(expr, predicate) ⇒ Object Also known as: on_clip, on_sort, on_project


22
23
24
# File 'lib/alf/update/deleter.rb', line 22

def on_unary_delegate(expr, predicate)
  apply(expr.operand, predicate)
end

#on_wrap(expr, predicate) ⇒ Object


92
93
94
# File 'lib/alf/update/deleter.rb', line 92

def on_wrap(expr, predicate)
  apply_and_split(expr, predicate, AttrList[expr.as])
end