Class: Bmg::Sql::Processor::Rename
- Inherits:
-
Bmg::Sql::Processor
- Object
- Sexpr::Rewriter
- Bmg::Sql::Processor
- Bmg::Sql::Processor::Rename
- Defined in:
- lib/bmg/sql/processor/rename.rb
Constant Summary
Constants inherited from Bmg::Sql::Processor
Instance Attribute Summary
Attributes inherited from Bmg::Sql::Processor
Instance Method Summary collapse
-
#initialize(renaming, builder) ⇒ Rename
constructor
A new instance of Rename.
- #on_select_item(sexpr) ⇒ Object
- #on_select_list(sexpr) ⇒ Object
Methods inherited from Bmg::Sql::Processor
#on_select_exp, #on_set_operator, #on_with_exp
Constructor Details
#initialize(renaming, builder) ⇒ Rename
Returns a new instance of Rename.
6 7 8 9 |
# File 'lib/bmg/sql/processor/rename.rb', line 6 def initialize(renaming, builder) super(builder) @renaming = renaming end |
Instance Method Details
#on_select_item(sexpr) ⇒ Object
17 18 19 20 |
# File 'lib/bmg/sql/processor/rename.rb', line 17 def on_select_item(sexpr) return sexpr unless newname = @renaming[sexpr.as_name.to_sym] builder.select_item(sexpr.qualifier, sexpr.would_be_name, newname.to_s) end |
#on_select_list(sexpr) ⇒ Object
11 12 13 14 15 |
# File 'lib/bmg/sql/processor/rename.rb', line 11 def on_select_list(sexpr) sexpr.each_with_index.map{|child,index| index == 0 ? child : apply(child) } end |