Sha256: 42dc1ed9b388df9e680960ce8eaef52d1a285a668048438bdca01ff74d7d812b

Contents?: true

Size: 630 Bytes

Versions: 5

Compression:

Stored size: 630 Bytes

Contents

module Alf
  module Sql
    class Processor
      class Rename < Processor

        def initialize(renaming, builder)
          super(builder)
          @renaming = renaming
        end

        def on_select_list(sexpr)
          sexpr.each_with_index.map{|child,index|
            index == 0 ? child : apply(child)
          }
        end

        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

      end # class Rename
    end # class Processor
  end # module Sql
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-sql-0.16.3 lib/alf/sql/processor/rename.rb
alf-sql-0.16.2 lib/alf/sql/processor/rename.rb
alf-sql-0.16.1 lib/alf/sql/processor/rename.rb
alf-sql-0.16.0 lib/alf/sql/processor/rename.rb
alf-sql-0.15.0 lib/alf/sql/processor/rename.rb