Class: Bmg::Sql::Processor::Transform
- Inherits:
-
Bmg::Sql::Processor
- Object
- Sexpr::Rewriter
- Bmg::Sql::Processor
- Bmg::Sql::Processor::Transform
- Defined in:
- lib/bmg/sql/processor/transform.rb
Defined Under Namespace
Modules: SplitSupported
Constant Summary
Constants inherited from Bmg::Sql::Processor
Instance Attribute Summary collapse
-
#transformation ⇒ Object
readonly
Returns the value of attribute transformation.
Attributes inherited from Bmg::Sql::Processor
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(transformation, options, builder) ⇒ Transform
constructor
module SplitSupported.
- #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(transformation, options, builder) ⇒ Transform
module SplitSupported
42 43 44 45 46 |
# File 'lib/bmg/sql/processor/transform.rb', line 42 def initialize(transformation, , builder) raise NotSupportedError unless .empty? super(builder) @transformation = transformation end |
Instance Attribute Details
#transformation ⇒ Object (readonly)
Returns the value of attribute transformation.
47 48 49 |
# File 'lib/bmg/sql/processor/transform.rb', line 47 def transformation @transformation end |
Class Method Details
.split_supported(*args, &bl) ⇒ Object
49 50 51 |
# File 'lib/bmg/sql/processor/transform.rb', line 49 def self.split_supported(*args, &bl) SplitSupported.split_supported(*args, &bl) end |
Instance Method Details
#on_select_item(sexpr) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/bmg/sql/processor/transform.rb', line 59 def on_select_item(sexpr) as = sexpr.as_name.to_sym case t = transformation_for(as) when NilClass sexpr when Class, Array sexpr([:select_item, func_call_node(sexpr, Array(t).reverse), sexpr[2] ]) else raise NotSupportedError end end |
#on_select_list(sexpr) ⇒ Object
53 54 55 56 57 |
# File 'lib/bmg/sql/processor/transform.rb', line 53 def on_select_list(sexpr) sexpr.each_with_index.map{|child,index| index == 0 ? child : apply(child) } end |