Sha256: 99edd988976e195cc98050f3e2968813e0b721b14415779263855f8351491572

Contents?: true

Size: 542 Bytes

Versions: 16

Compression:

Stored size: 542 Bytes

Contents

module Bmg
  module Sql
    class Processor
      class Reorder < Processor

        def initialize(attr_list, builder)
          super(builder)
          @indexes = Hash[attr_list.to_a.map(&:to_s).each_with_index.to_a]
        end

        def on_select_list(sexpr)
          reordered = sexpr.sexpr_body.sort{|i1,i2|
            @indexes[i1.as_name.to_s] <=> @indexes[i2.as_name.to_s]
          }
          reordered.unshift(:select_list)
        end

      end # class Reorder
    end # class Processor
  end # module Sql
end # module Bmg

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
bmg-0.23.3 lib/bmg/sql/processor/reorder.rb
bmg-0.23.2 lib/bmg/sql/processor/reorder.rb
bmg-0.23.1 lib/bmg/sql/processor/reorder.rb
bmg-0.23.0 lib/bmg/sql/processor/reorder.rb
bmg-0.21.5 lib/bmg/sql/processor/reorder.rb
bmg-0.21.4 lib/bmg/sql/processor/reorder.rb
bmg-0.20.5 lib/bmg/sql/processor/reorder.rb
bmg-0.19.3 lib/bmg/sql/processor/reorder.rb
bmg-0.21.3 lib/bmg/sql/processor/reorder.rb
bmg-0.21.2 lib/bmg/sql/processor/reorder.rb
bmg-0.21.0 lib/bmg/sql/processor/reorder.rb
bmg-0.20.4 lib/bmg/sql/processor/reorder.rb
bmg-0.20.2 lib/bmg/sql/processor/reorder.rb
bmg-0.20.1 lib/bmg/sql/processor/reorder.rb
bmg-0.20.0 lib/bmg/sql/processor/reorder.rb
bmg-0.19.2 lib/bmg/sql/processor/reorder.rb