Sha256: 7cc0502246fbb72c145ef68e48fecde2df1be7586a25ec815b1934b51e4c9426

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

module Arel
  module SqlToArel
    class Result < Array
      def to_sql(engine = Arel::Table.engine)
        sql, _binds = to_sql_and_binds(engine)
        sql
      end

      def to_sql_and_binds(engine = Arel::Table.engine)
        sql_collection = []
        binds_collection = []

        each do |item|
          sql, binds = item.to_sql_and_binds(engine)
          sql_collection << sql
          binds_collection.concat(binds) unless binds.nil?
        end

        [
          sql_collection.join('; '),
          binds_collection,
        ]
      end

      def map(&block)
        Result.new super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arel_toolkit-0.4.9 lib/arel/sql_to_arel/result.rb