Class: Alf::Sql::Processor::Clip

Inherits:
Alf::Sql::Processor show all
Defined in:
lib/alf/sql/processor/clip.rb

Constant Summary

Constants inherited from Alf::Sql::Processor

UnexpectedError

Instance Attribute Summary collapse

Attributes inherited from Alf::Sql::Processor

#builder

Instance Method Summary collapse

Methods inherited from Alf::Sql::Processor

#on_with_exp

Constructor Details

#initialize(attributes, on_empty = :is_table_dee, builder) ⇒ Clip

Returns a new instance of Clip.



6
7
8
9
10
# File 'lib/alf/sql/processor/clip.rb', line 6

def initialize(attributes, on_empty = :is_table_dee, builder)
  super(builder)
  @attributes = attributes
  @on_empty = on_empty
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



11
12
13
# File 'lib/alf/sql/processor/clip.rb', line 11

def attributes
  @attributes
end

#on_emptyObject (readonly)

Returns the value of attribute on_empty.



11
12
13
# File 'lib/alf/sql/processor/clip.rb', line 11

def on_empty
  @on_empty
end

Instance Method Details

#on_select_exp(sexpr) ⇒ Object



20
21
22
23
# File 'lib/alf/sql/processor/clip.rb', line 20

def on_select_exp(sexpr)
  catch(:empty){ return super(sexpr) }
  send("select_#{on_empty}", sexpr)
end

#on_select_list(sexpr) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/alf/sql/processor/clip.rb', line 25

def on_select_list(sexpr)
  result = sexpr.select{|child|
    (child == :select_list) or
    attributes.include?(child.as_name.to_sym)
  }
  (result.size==1) ? throw(:empty) : result
end

#on_set_operator(sexpr) ⇒ Object Also known as: on_union, on_except, on_intersect



13
14
15
# File 'lib/alf/sql/processor/clip.rb', line 13

def on_set_operator(sexpr)
  apply(builder.from_self(sexpr))
end