Permalink
Browse files

initialize instance variables to avoid conditionals

  • Loading branch information...
1 parent d0d4ef6 commit 73eeb51ea59c62dc528ad71a439bd2088edad850 @tenderlove tenderlove committed Aug 20, 2012
@@ -1,6 +1,12 @@
module ActiveRecord
module ConnectionAdapters # :nodoc:
module DatabaseStatements
+ def initialize
+ super
+ @_current_transaction_records = []
+ @transaction_joinable = nil
+ end
+
# Converts an arel AST to SQL
def to_sql(arel, binds = [])
if arel.respond_to?(:ast)
@@ -167,7 +173,7 @@ def supports_statement_cache?
def transaction(options = {})
options.assert_valid_keys :requires_new, :joinable
- last_transaction_joinable = defined?(@transaction_joinable) ? @transaction_joinable : nil
+ last_transaction_joinable = @transaction_joinable
if options.has_key?(:joinable)
@transaction_joinable = options[:joinable]
else
@@ -176,7 +182,6 @@ def transaction(options = {})
requires_new = options[:requires_new] || !last_transaction_joinable
transaction_open = false
- @_current_transaction_records ||= []
begin
if block_given?

0 comments on commit 73eeb51

Please sign in to comment.