Sha256: 2231dac038766a5ab1dfc52979d3051cdb2191515ebc7af0da5fa666d865647f
Contents?: true
Size: 1.21 KB
Versions: 11
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Switchman module ActiveRecord module Persistence # touch reads the id attribute directly, so it's not relative to the current shard def touch(*, **) writable_shadow_record_warning shard.activate(self.class.connection_class_for_self) { super } end def update_columns(*) writable_shadow_record_warning shard.activate(self.class.connection_class_for_self) { super } end def delete db = shard.database_server db.unguard { super } end def destroy writable_shadow_record_warning super end def create_or_update(**, &block) writable_shadow_record_warning super end def reload(*) res = super # When a shadow record is reloaded the real record is returned. So # we need to ensure the loaded_from_shard is set correctly after a reload. @loaded_from_shard = @shard res end def writable_shadow_record_warning return unless shadow_record? && Switchman.config[:writable_shadow_records] Switchman::Deprecation.warn("writing to shadow records is not supported") end end end end
Version data entries
11 entries across 11 versions & 1 rubygems