fresh_connection 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e470a4665ec85ef6b012e95e365c5038d996aa6
|
4
|
+
data.tar.gz: a764c721578fbdc080d2351333dbd34716be123a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98a9036418869064befea2b8d7f9e539a30bc11a74ab3b3039057f9a00224339855612de0586bdd7cb1aeef451c09fa65ecb51c6378182a6b43151d3788aed9f
|
7
|
+
data.tar.gz: 4456c9b0d2798facd1b8b3c83a55f7d61b52c8708ce899266ac4307b1034290474639dde84909099be02c42d253fce5bbfcf07f2182115f5d51aa13e4ddb67a3
|
@@ -16,10 +16,6 @@ module FreshConnection
|
|
16
16
|
@klass.manage_access(slave_access) { super }
|
17
17
|
end
|
18
18
|
|
19
|
-
def pluck(*args)
|
20
|
-
@klass.manage_access(enable_slave_access) { super }
|
21
|
-
end
|
22
|
-
|
23
19
|
private
|
24
20
|
|
25
21
|
def exec_queries_with_fresh_connection
|
@@ -31,14 +27,36 @@ module FreshConnection
|
|
31
27
|
end
|
32
28
|
|
33
29
|
module ForRails4
|
30
|
+
def pluck(*args)
|
31
|
+
@klass.manage_access(enable_slave_access) { super }
|
32
|
+
end
|
33
|
+
|
34
34
|
private
|
35
|
+
|
35
36
|
def enable_slave_access
|
36
37
|
connection.open_transactions == 0 && (readonly_value.nil? || readonly_value)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
module ForRails3
|
42
|
+
def pluck(column_name)
|
43
|
+
if column_name.is_a?(Symbol) && column_names.include?(column_name.to_s)
|
44
|
+
column_name = "#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column_name)}"
|
45
|
+
end
|
46
|
+
|
47
|
+
result = @klass.manage_access(enable_slave_access) do
|
48
|
+
klass.connection.select_all(select(column_name).arel, nil)
|
49
|
+
end
|
50
|
+
|
51
|
+
last_columns = result.last.keys.last
|
52
|
+
|
53
|
+
result.map do |attributes|
|
54
|
+
klass.type_cast_attribute(last_columns, klass.initialize_attributes(attributes))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
41
58
|
private
|
59
|
+
|
42
60
|
def enable_slave_access
|
43
61
|
connection.open_transactions == 0 && (@readonly_value.nil? || @readonly_value)
|
44
62
|
end
|
@@ -4,16 +4,15 @@ module FreshConnection
|
|
4
4
|
def self.included(base)
|
5
5
|
base.__send__(:attr_writer, :model_class)
|
6
6
|
base.alias_method_chain :configure_connection, :fresh_connection
|
7
|
-
base.alias_method_chain :execute, :fresh_connection
|
8
7
|
end
|
9
8
|
|
10
|
-
def
|
11
|
-
if
|
9
|
+
def select_all(arel, name = nil, binds = [])
|
10
|
+
if FreshConnection::AccessControl.slave_access?
|
12
11
|
change_connection do
|
13
|
-
|
12
|
+
super(arel, "[#{@model_class.slave_group}] #{name}", binds)
|
14
13
|
end
|
15
14
|
else
|
16
|
-
|
15
|
+
super
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fresh_connection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tsukasa OISHI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|