Sha256: a61e3fbf99682eae68edc124391997b9e3f1d821c0dec10b45f40c962d074a2e
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
module FreshConnection module Extend module ArRelation def self.included(base) base.alias_method_chain :exec_queries, :fresh_connection if FreshConnection.rails_4? base.__send__(:include, ForRails4) elsif FreshConnection.rails_3? base.__send__(:include, ForRails3) end end def calculate(operation, column_name, options = {}) slave_access = enable_slave_access && options[:readonly] != false @klass.manage_access(slave_access) { super } end def pluck(*args) @klass.manage_access(enable_slave_access) { super } end private def exec_queries_with_fresh_connection return @records if loaded? @klass.manage_access(enable_slave_access) do exec_queries_without_fresh_connection end end module ForRails4 private def enable_slave_access connection.open_transactions == 0 && (readonly_value.nil? || readonly_value) end end module ForRails3 private def enable_slave_access connection.open_transactions == 0 && (@readonly_value.nil? || @readonly_value) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fresh_connection-0.2.4 | lib/fresh_connection/extend/ar_relation.rb |