Class: Arel::SqlToArel::Result

Inherits:
Array
  • Object
show all
Defined in:
lib/arel/sql_to_arel/result.rb

Instance Method Summary collapse

Instance Method Details

#map(&block) ⇒ Object



25
26
27
# File 'lib/arel/sql_to_arel/result.rb', line 25

def map(&block)
  Result.new super
end

#to_sql(engine = Arel::Table.engine) ⇒ Object



4
5
6
7
# File 'lib/arel/sql_to_arel/result.rb', line 4

def to_sql(engine = Arel::Table.engine)
  sql, _binds = to_sql_and_binds(engine)
  sql
end

#to_sql_and_binds(engine = Arel::Table.engine) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/arel/sql_to_arel/result.rb', line 9

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