active_remote 1.7.0 → 1.7.1
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: 4e0a0b815dc24d0ba8c884b135055cc9fb42fbc0
|
4
|
+
data.tar.gz: 59144b3bb85ecebf7e660e0b5a93a27db60f7751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac81f4a6f6f7206306e2712a0fb5fe6d90f72228ce63667f480f609d32243e3bee20ad3465cd2766893994ee01c34733a411c9ee5e047cb89781de47d4262d78
|
7
|
+
data.tar.gz: 471a29c7b76006c8d8fd86835196a3ad5dbbbe76c419c9e5cca6d7f1b86e195fb9b2b149185348fa34df1e8875aba8260a9821838e689ced9d75c9b2b0cd3062
|
data/active_remote.gemspec
CHANGED
data/lib/active_remote/base.rb
CHANGED
@@ -119,11 +119,25 @@ module ActiveRemote
|
|
119
119
|
return respond_to?(:errors) && errors.present?
|
120
120
|
end
|
121
121
|
|
122
|
+
# Instantiate a record with the given remote attributes. Generally used
|
123
|
+
# when retrieving records that already exist, so @new_record is set to false.
|
124
|
+
#
|
125
|
+
def instantiate(record)
|
126
|
+
skip_dirty_tracking do
|
127
|
+
assign_attributes(record)
|
128
|
+
end
|
129
|
+
|
130
|
+
run_callbacks :initialize
|
131
|
+
|
132
|
+
@new_record = false
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
122
136
|
# Returns true if the remote record hasn't been saved yet; otherwise,
|
123
137
|
# returns false.
|
124
138
|
#
|
125
139
|
def new_record?
|
126
|
-
|
140
|
+
@new_record
|
127
141
|
end
|
128
142
|
|
129
143
|
# Returns true if the remote record has been saved; otherwise, returns false.
|
@@ -207,6 +221,7 @@ module ActiveRemote
|
|
207
221
|
assign_attributes(last_response.to_hash)
|
208
222
|
add_errors_from_response
|
209
223
|
|
224
|
+
@new_record = has_errors?
|
210
225
|
success?
|
211
226
|
end
|
212
227
|
end
|
@@ -31,9 +31,10 @@ module ActiveRemote
|
|
31
31
|
def serialize_records
|
32
32
|
return nil unless last_response.respond_to?(:records)
|
33
33
|
|
34
|
-
last_response.records.map do |
|
35
|
-
|
36
|
-
|
34
|
+
last_response.records.map do |remote_record|
|
35
|
+
record = self.class.allocate
|
36
|
+
record.instantiate(remote_record.to_hash)
|
37
|
+
record
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
@@ -146,7 +146,7 @@ describe ActiveRemote::Persistence do
|
|
146
146
|
|
147
147
|
describe "#new_record?" do
|
148
148
|
context "when the record is persisted" do
|
149
|
-
subject { Tag.
|
149
|
+
subject { Tag.allocate.instantiate(:guid => 'foo') }
|
150
150
|
|
151
151
|
its(:new_record?) { should be_false }
|
152
152
|
end
|
@@ -159,13 +159,13 @@ describe ActiveRemote::Persistence do
|
|
159
159
|
end
|
160
160
|
|
161
161
|
describe "#persisted?" do
|
162
|
-
context "when the record
|
163
|
-
subject { Tag.
|
162
|
+
context "when the record is persisted" do
|
163
|
+
subject { Tag.allocate.instantiate(:guid => 'foo') }
|
164
164
|
|
165
165
|
its(:persisted?) { should be_true }
|
166
166
|
end
|
167
167
|
|
168
|
-
context "when the record
|
168
|
+
context "when the record is not persisted" do
|
169
169
|
subject { Tag.new }
|
170
170
|
|
171
171
|
its(:persisted?) { should be_false }
|
@@ -194,7 +194,7 @@ describe ActiveRemote::Persistence do
|
|
194
194
|
context "when the record is not new" do
|
195
195
|
let(:attributes) { { 'guid' => 'foo' } }
|
196
196
|
|
197
|
-
subject { Tag.
|
197
|
+
subject { Tag.allocate.instantiate(attributes) }
|
198
198
|
|
199
199
|
it "updates the record" do
|
200
200
|
subject.should_receive(:execute).with(:update, attributes)
|
@@ -204,14 +204,14 @@ describe ActiveRemote::Persistence do
|
|
204
204
|
|
205
205
|
context "when the record is saved" do
|
206
206
|
it "returns true" do
|
207
|
-
subject.
|
207
|
+
subject.better_stub(:has_errors?) { false }
|
208
208
|
subject.save.should be_true
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
212
|
context "when the record is not saved" do
|
213
213
|
it "returns false" do
|
214
|
-
subject.
|
214
|
+
subject.better_stub(:has_errors?) { true }
|
215
215
|
subject.save.should be_false
|
216
216
|
end
|
217
217
|
end
|
@@ -267,7 +267,7 @@ describe ActiveRemote::Persistence do
|
|
267
267
|
after { Tag.any_instance.unstub(:execute) }
|
268
268
|
|
269
269
|
it "runs update callbacks" do
|
270
|
-
tag = Tag.
|
270
|
+
tag = Tag.allocate.instantiate({:guid => "123"})
|
271
271
|
tag.should_receive(:after_update_callback)
|
272
272
|
tag.update_attributes({})
|
273
273
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_remote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Hutchison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_attr
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: better_receive
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,8 +240,41 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
240
|
version: '0'
|
227
241
|
requirements: []
|
228
242
|
rubyforge_project:
|
229
|
-
rubygems_version: 2.
|
243
|
+
rubygems_version: 2.1.11
|
230
244
|
signing_key:
|
231
245
|
specification_version: 4
|
232
246
|
summary: Active Record for your platform
|
233
|
-
test_files:
|
247
|
+
test_files:
|
248
|
+
- spec/core_ext/date_time_spec.rb
|
249
|
+
- spec/lib/active_remote/association_spec.rb
|
250
|
+
- spec/lib/active_remote/base_spec.rb
|
251
|
+
- spec/lib/active_remote/bulk_spec.rb
|
252
|
+
- spec/lib/active_remote/dirty_spec.rb
|
253
|
+
- spec/lib/active_remote/dsl_spec.rb
|
254
|
+
- spec/lib/active_remote/integration_spec.rb
|
255
|
+
- spec/lib/active_remote/persistence_spec.rb
|
256
|
+
- spec/lib/active_remote/publication_spec.rb
|
257
|
+
- spec/lib/active_remote/rpc_spec.rb
|
258
|
+
- spec/lib/active_remote/search_spec.rb
|
259
|
+
- spec/lib/active_remote/serialization_spec.rb
|
260
|
+
- spec/lib/active_remote/serializers/json_spec.rb
|
261
|
+
- spec/lib/active_remote/serializers/protobuf_spec.rb
|
262
|
+
- spec/spec_helper.rb
|
263
|
+
- spec/support/definitions/author.proto
|
264
|
+
- spec/support/definitions/post.proto
|
265
|
+
- spec/support/definitions/support/protobuf/category.proto
|
266
|
+
- spec/support/definitions/support/protobuf/error.proto
|
267
|
+
- spec/support/definitions/tag.proto
|
268
|
+
- spec/support/helpers.rb
|
269
|
+
- spec/support/models.rb
|
270
|
+
- spec/support/models/author.rb
|
271
|
+
- spec/support/models/category.rb
|
272
|
+
- spec/support/models/message_with_options.rb
|
273
|
+
- spec/support/models/post.rb
|
274
|
+
- spec/support/models/tag.rb
|
275
|
+
- spec/support/protobuf.rb
|
276
|
+
- spec/support/protobuf/author.pb.rb
|
277
|
+
- spec/support/protobuf/category.pb.rb
|
278
|
+
- spec/support/protobuf/error.pb.rb
|
279
|
+
- spec/support/protobuf/post.pb.rb
|
280
|
+
- spec/support/protobuf/tag.pb.rb
|