Class: Bmg::Sql::Processor::Clip
- Inherits:
-
Bmg::Sql::Processor
- Object
- Sexpr::Rewriter
- Bmg::Sql::Processor
- Bmg::Sql::Processor::Clip
- Defined in:
- lib/bmg/sql/processor/clip.rb
Constant Summary
Constants inherited from Bmg::Sql::Processor
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#on_empty ⇒ Object
readonly
Returns the value of attribute on_empty.
Attributes inherited from Bmg::Sql::Processor
Instance Method Summary collapse
- #allbut? ⇒ Boolean
-
#initialize(attributes, allbut = false, on_empty = :is_table_dee, builder) ⇒ Clip
constructor
A new instance of Clip.
- #on_select_exp(sexpr) ⇒ Object
- #on_select_list(sexpr) ⇒ Object
- #on_select_star(sexpr) ⇒ Object
- #on_set_operator(sexpr) ⇒ Object (also: #on_union, #on_except, #on_intersect)
Methods inherited from Bmg::Sql::Processor
Constructor Details
#initialize(attributes, allbut = false, on_empty = :is_table_dee, builder) ⇒ Clip
Returns a new instance of Clip.
6 7 8 9 10 11 |
# File 'lib/bmg/sql/processor/clip.rb', line 6 def initialize(attributes, allbut = false, on_empty = :is_table_dee, builder) super(builder) @attributes = attributes @allbut = allbut @on_empty = on_empty end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
12 13 14 |
# File 'lib/bmg/sql/processor/clip.rb', line 12 def attributes @attributes end |
#on_empty ⇒ Object (readonly)
Returns the value of attribute on_empty.
12 13 14 |
# File 'lib/bmg/sql/processor/clip.rb', line 12 def on_empty @on_empty end |
Instance Method Details
#allbut? ⇒ Boolean
14 15 16 |
# File 'lib/bmg/sql/processor/clip.rb', line 14 def allbut? @allbut end |
#on_select_exp(sexpr) ⇒ Object
25 26 27 28 |
# File 'lib/bmg/sql/processor/clip.rb', line 25 def on_select_exp(sexpr) catch(:empty){ return super(sexpr) } send("select_#{on_empty}", sexpr) end |
#on_select_list(sexpr) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/bmg/sql/processor/clip.rb', line 35 def on_select_list(sexpr) allbut = self.allbut? result = sexpr.select{|child| (child == :select_list) or attributes.include?(child.as_name.to_sym) == !allbut } (result.size==1) ? throw(:empty) : result end |
#on_select_star(sexpr) ⇒ Object
30 31 32 33 |
# File 'lib/bmg/sql/processor/clip.rb', line 30 def on_select_star(sexpr) raise NotImplementedError, "Allbut on * is not supported" if allbut? builder.select_list(attributes, builder.last_qualifier) end |
#on_set_operator(sexpr) ⇒ Object Also known as: on_union, on_except, on_intersect
18 19 20 |
# File 'lib/bmg/sql/processor/clip.rb', line 18 def on_set_operator(sexpr) apply(builder.from_self(sexpr)) end |