Module: Returning::ActiveRecord::Adapter
- Defined in:
- lib/returning/active_record/adapter.rb
Instance Method Summary collapse
- #exec_with_returning(sql, binds) ⇒ Object
- #returning(columns, klass) ⇒ Object
- #returning? ⇒ Boolean
- #to_sql(arel) ⇒ Object
Instance Method Details
#exec_with_returning(sql, binds) ⇒ Object
16 17 18 19 20 |
# File 'lib/returning/active_record/adapter.rb', line 16 def exec_with_returning(sql, binds) records = @_returning[1].find_by_sql("#{to_sql(sql)} RETURNING #{@_returning[0]}", binds) records.each { |r| r.readonly! } records end |
#returning(columns, klass) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/returning/active_record/adapter.rb', line 46 def returning(columns, klass) old_returning, @_returning = @_returning, [columns, klass] yield ensure @_returning = old_returning end |
#returning? ⇒ Boolean
12 13 14 |
# File 'lib/returning/active_record/adapter.rb', line 12 def returning? !!@_returning end |
#to_sql(arel) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/returning/active_record/adapter.rb', line 4 def to_sql(arel) if arel.respond_to?(:ast) visitor.accept(arel.ast) else arel end end |