From e4213e7c682f2b4bf19383ea1af1681c81c96ac5 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 13 Jan 2019 10:10:06 +0900 Subject: 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. --- .../lib/active_record/connection_adapters/abstract_adapter.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'activerecord') 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: -- cgit v1.2.3