Sha256: 3d97237901749c9a363ea64624dc6875332891947469a60e44581f3c625fdedf
Contents?: true
Size: 1.05 KB
Versions: 11
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module FreshConnection module Extend module ArRelation def calculate(*args) manage_access { super } end def exists?(*args) manage_access { super } end def pluck(*args) manage_access { super } end def read_master spawn.read_master! end def read_master! self.read_master_value = true self end def read_master_value @values[:read_master] end def read_master_value=(value) raise ImmutableRelation if @loaded @values[:read_master] = value end def manage_access(replica_access: enable_replica_access, &block) FreshConnection::AccessControl.manage_access( model: @klass, replica_access: replica_access, &block ) end private def exec_queries manage_access { super } end def enable_replica_access connection.open_transactions.zero? && !read_master_value end end end end
Version data entries
11 entries across 11 versions & 1 rubygems