acts_as_shardable 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/acts_as_shardable.rb +25 -4
- data/lib/acts_as_shardable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c9172b2f82fbea155128f345ecae6cab923063c
|
4
|
+
data.tar.gz: 43ad2c18cc54d981ec0950a17342c9ef67703400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4c19e21693b35e9cbdba40a4aa83986460fc459a507880f030565b18b9880feb854c43300aef0ce57bbe1a36ac313a744db84f63e34726c733ef9f242b1c484
|
7
|
+
data.tar.gz: ce68c98e2754306f54fe456e4de992ada78d5a3a6492df3769b73ba8eb7c999187fba0206f6f2143c598b70d0c53ea85f33b3e38ffbf4a40f10d1720c2ecdbba
|
data/lib/acts_as_shardable.rb
CHANGED
@@ -43,7 +43,7 @@ module ActsAsShardable
|
|
43
43
|
attribute_names.uniq!
|
44
44
|
|
45
45
|
begin
|
46
|
-
relation =
|
46
|
+
relation = shard.unscoped
|
47
47
|
|
48
48
|
affected_rows = relation.where(
|
49
49
|
self.class.primary_key => id,
|
@@ -66,7 +66,15 @@ module ActsAsShardable
|
|
66
66
|
raise
|
67
67
|
end
|
68
68
|
else
|
69
|
-
|
69
|
+
attribute_names = attributes_for_update(attribute_names)
|
70
|
+
|
71
|
+
attributes_values = {}
|
72
|
+
arel_table = shard.arel_table
|
73
|
+
|
74
|
+
attribute_names.each do |name|
|
75
|
+
attributes_values[arel_table[name]] = typecasted_attribute_value(name)
|
76
|
+
end
|
77
|
+
|
70
78
|
if attributes_values.empty?
|
71
79
|
0
|
72
80
|
else
|
@@ -153,8 +161,21 @@ module ActsAsShardable
|
|
153
161
|
end
|
154
162
|
end
|
155
163
|
|
156
|
-
define_method :
|
157
|
-
|
164
|
+
define_method :reload do |options = nil|
|
165
|
+
clear_aggregation_cache
|
166
|
+
clear_association_cache
|
167
|
+
shard.connection.clear_query_cache
|
168
|
+
|
169
|
+
fresh_object =
|
170
|
+
if options && options[:lock]
|
171
|
+
shard.unscoped { shard.lock(options[:lock]).find(id) }
|
172
|
+
else
|
173
|
+
shard.unscoped { shard.find(id) }
|
174
|
+
end
|
175
|
+
|
176
|
+
@attributes = fresh_object.instance_variable_get('@attributes')
|
177
|
+
@new_record = false
|
178
|
+
fresh_object
|
158
179
|
end
|
159
180
|
end
|
160
181
|
|