Permalink
Browse files

Make ClosedTransaction a null object

  • Loading branch information...
1 parent dac9c92 commit 4140797967a8f50eccaa70614c01531dab6a90f4 @arthurnn arthurnn committed Jul 30, 2014
Showing with 6 additions and 16 deletions.
  1. +6 −16 activerecord/lib/active_record/connection_adapters/abstract/transaction.rb
@@ -50,7 +50,7 @@ def current_transaction
private
def closed_transaction
- @closed_transaction ||= ClosedTransaction.new(@connection)
+ @closed_transaction ||= ClosedTransaction.new
end
end
@@ -98,21 +98,12 @@ def set_state(state)
end
class ClosedTransaction < Transaction #:nodoc:
- def closed?
- true
- end
-
- def open?
- false
- end
-
- def joinable?
- false
- end
-
+ def initialize; super(nil); end
+ def closed?; true; end
+ def open?; false; end
+ def joinable?; false; end
# This is a noop when there are no open transactions
- def add_record(record)
- end
+ def add_record(record); end
end
class OpenTransaction < Transaction #:nodoc:
@@ -126,7 +117,6 @@ def initialize(connection, options = {})
@joinable = options.fetch(:joinable, true)
end
-
def joinable?
@joinable
end

0 comments on commit 4140797

Please sign in to comment.