Replacing Kernel#returning with Object#tap to avoid deprec warnings

pull/6827/head
Gregor Schmidt 14 years ago
parent 114ea9e561
commit b0c2c1a1af
  1. 4
      app/models/report/chainable.rb
  2. 4
      app/models/report/sql_statement.rb

@ -101,7 +101,7 @@ class Report < ActiveRecord::Base
end
def to_a
returning([to_hash]) { |a| a.unshift(*child.to_a) unless bottom? }
[to_hash].tap { |a| a.unshift(*child.to_a) unless bottom? }
end
def top
@ -293,4 +293,4 @@ class Report < ActiveRecord::Base
end
end
end
end

@ -171,7 +171,7 @@ class Report::SqlStatement
# @return [Array<String>] All fields/statements for select part
def select(*fields)
return(@select || default_select) if fields.empty?
returning(@select ||= []) do
(@select ||= []).tap do
@sql = nil
fields.each do |f|
case f
@ -200,7 +200,7 @@ class Report::SqlStatement
# @param [Array, String, Symbol] fields Fields to add
def group_by(*fields)
@sql = nil unless fields.empty?
returning(@group_by ||= []) do
(@group_by ||= []).tap do
fields.each do |e|
if e.is_a? Array and (e.size != 2 or !e.first.respond_to? :table_name)
group_by(*e)

Loading…
Cancel
Save