active_repository 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9ca952750bf1662400683fb0e3914c22951d50c
|
4
|
+
data.tar.gz: 076094f4e75ec626cd123e4595b382f2ffe648d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 104242bf4ac101b011cea78b38b5df354e3b894f52ed0cd3526a56cc3738613aff2edc88dd4e6cb0ba60442e44f28fcf408f6189565aa1a6c050db1507ec75be
|
7
|
+
data.tar.gz: d789d7b0745f60dc3b90a389d02be2ec757f521ac064cab0464f05aef27b76f19221ff24edc79f7b377c855d793cee2a2a56c823fd273892006b7536c8630cdb
|
@@ -77,6 +77,17 @@ class ActiveRepository::ResultSet
|
|
77
77
|
ActiveRepository::ResultSet.new(@klass, query, @attributes)
|
78
78
|
end
|
79
79
|
|
80
|
+
def update_all(attrs)
|
81
|
+
if @klass.repository?
|
82
|
+
@klass.where(@query).each do |record|
|
83
|
+
record.update_attributes(attrs)
|
84
|
+
end
|
85
|
+
else
|
86
|
+
query = SqlQueryExecutor::Base.new(@query)
|
87
|
+
PersistenceAdapter.where(@klass, query).update_all(attrs)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
80
91
|
private
|
81
92
|
def convert_query(query)
|
82
93
|
@query = SqlQueryExecutor::Query::Normalizers::QueryNormalizer.clean_query(query)
|
@@ -74,6 +74,7 @@ describe ActiveRepository, "Base" do
|
|
74
74
|
it_behaves_like '.serialized_attributes'
|
75
75
|
it_behaves_like '.update_attribute'
|
76
76
|
it_behaves_like '.update_attributes'
|
77
|
+
it_behaves_like '.update_all'
|
77
78
|
it_behaves_like '.all'
|
78
79
|
it_behaves_like '.where'
|
79
80
|
it_behaves_like '.exists?'
|
@@ -142,6 +143,7 @@ describe ActiveRepository, "Base" do
|
|
142
143
|
it_behaves_like '.serialized_attributes'
|
143
144
|
it_behaves_like '.update_attribute'
|
144
145
|
it_behaves_like '.update_attributes'
|
146
|
+
it_behaves_like '.update_all'
|
145
147
|
it_behaves_like '.all'
|
146
148
|
it_behaves_like '.where'
|
147
149
|
it_behaves_like '.exists?'
|
@@ -215,6 +217,7 @@ describe ActiveRepository, "Base" do
|
|
215
217
|
it_behaves_like '.serialized_attributes'
|
216
218
|
it_behaves_like '.update_attribute'
|
217
219
|
it_behaves_like '.update_attributes'
|
220
|
+
it_behaves_like '.update_all'
|
218
221
|
it_behaves_like '.all'
|
219
222
|
it_behaves_like '.where'
|
220
223
|
it_behaves_like '.exists?'
|
@@ -21,7 +21,7 @@ shared_examples ".update_attribute" do
|
|
21
21
|
Country.first.name.should == "Italy"
|
22
22
|
end
|
23
23
|
|
24
|
-
it "updates records
|
24
|
+
it "updates records with string keys" do
|
25
25
|
id = Country.first.id
|
26
26
|
country = Country.find(id)
|
27
27
|
country.update_attribute('name', "Germany")
|
@@ -39,7 +39,7 @@ shared_examples ".update_attributes" do
|
|
39
39
|
Country.first.name.should == "Italy"
|
40
40
|
end
|
41
41
|
|
42
|
-
it "updates records
|
42
|
+
it "updates records with string keys" do
|
43
43
|
id = Country.first.id
|
44
44
|
country = Country.find(id)
|
45
45
|
country.update_attributes('name' => "Germany")
|
@@ -48,6 +48,26 @@ shared_examples ".update_attributes" do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
shared_examples ".update_all" do
|
52
|
+
it "updates records" do
|
53
|
+
country = Country.where(language: 'English')
|
54
|
+
country.update_all(name: "Italy")
|
55
|
+
|
56
|
+
italys = Country.where(name: 'Italy')
|
57
|
+
|
58
|
+
italys.count.should == 3
|
59
|
+
end
|
60
|
+
|
61
|
+
it "updates records with string keys" do
|
62
|
+
country = Country.where(language: 'English')
|
63
|
+
country.update_all('name' => "Germany")
|
64
|
+
|
65
|
+
germanys = Country.where(name: 'Germany')
|
66
|
+
|
67
|
+
germanys.count.should == 3
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
51
71
|
shared_examples ".all" do
|
52
72
|
it "returns an empty array if data is nil" do
|
53
73
|
Country.delete_all
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_repository
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caio Torres
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_hash
|