aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-01-13 10:10:06 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-01-15 22:55:31 +0900
commite4213e7c682f2b4bf19383ea1af1681c81c96ac5 (patch)
treeb339cbd8a8b60913738ea3e1b6ed4bc43ab6f773
parent8056fe0d964a8d0add46d4b545e396e5fadfcbe3 (diff)
downloadrails-e4213e7c682f2b4bf19383ea1af1681c81c96ac5.tar.gz
rails-e4213e7c682f2b4bf19383ea1af1681c81c96ac5.tar.bz2
rails-e4213e7c682f2b4bf19383ea1af1681c81c96ac5.zip
Remove public `prevent_writes` writer
The `@prevent_writes` should be updated only in the `while_preventing_writes`, it is not necessary to expose the attr writer.
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_adapter.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index 0065d7c349..d1ff32df3f 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -80,8 +80,8 @@ module ActiveRecord
attr_writer :visitor
deprecate :visitor=
- attr_accessor :pool, :prevent_writes
- attr_reader :schema_cache, :visitor, :owner, :logger, :prepared_statements, :lock
+ attr_accessor :pool
+ attr_reader :schema_cache, :visitor, :owner, :logger, :lock, :prepared_statements, :prevent_writes
alias :in_use? :owner
set_callback :checkin, :after, :enable_lazy_transactions!
@@ -121,6 +121,7 @@ module ActiveRecord
@idle_since = Concurrent.monotonic_time
@schema_cache = SchemaCache.new self
@quoted_column_names, @quoted_table_names = {}, {}
+ @prevent_writes = false
@visitor = arel_visitor
@lock = ActiveSupport::Concurrency::LoadInterlockAwareMonitor.new
@@ -156,11 +157,10 @@ module ActiveRecord
# even if you are on a database that can write. `while_preventing_writes`
# will prevent writes to the database for the duration of the block.
def while_preventing_writes
- original = self.prevent_writes
- self.prevent_writes = true
+ original, @prevent_writes = @prevent_writes, true
yield
ensure
- self.prevent_writes = original
+ @prevent_writes = original
end
def migrations_paths # :nodoc: