restforce-db 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/restforce/db/accumulator.rb +15 -2
- data/lib/restforce/db/version.rb +1 -1
- data/test/lib/restforce/db/accumulator_test.rb +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a843ad27395ce855fbdd44478f7a84f19cbf612c
|
4
|
+
data.tar.gz: ddb16c66bf0df55d2b35bb6da9efbf99cde55c7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0a7519e5d68a8977aeadf0a2492a9387a30e6ad3e74a73b57065be636e04e4299fa389dad03bdd834361f7edde3da0d4567be78bc9f5cd8058ad731a5ffe935
|
7
|
+
data.tar.gz: 247be2475029efcdc8eaa247c43001f93fd7f1713a1cbb9319c5d7182f2ea8b22dcf486fba0d2f7e616f75e5f4a6f502fab188a18cc878732151aa5deaefe595
|
@@ -8,13 +8,26 @@ module Restforce
|
|
8
8
|
# is then applied to all objects synchronized with that Salesforce object.
|
9
9
|
class Accumulator < Hash
|
10
10
|
|
11
|
+
# Public: Store the changeset under the given timestamp. If a changeset
|
12
|
+
# for that timestamp has already been registered, merge it with the newly
|
13
|
+
# passed changeset.
|
14
|
+
#
|
15
|
+
# timestamp - A Time object.
|
16
|
+
# changeset - A Hash mapping attribute names to values.
|
17
|
+
#
|
18
|
+
# Returns nothing.
|
19
|
+
def store(timestamp, changeset)
|
20
|
+
return super unless key?(timestamp)
|
21
|
+
self[timestamp].merge!(changeset)
|
22
|
+
end
|
23
|
+
|
11
24
|
# Public: Get the accumulated list of attributes after all changes have
|
12
25
|
# been applied.
|
13
26
|
#
|
14
27
|
# Returns a Hash.
|
15
28
|
def attributes
|
16
|
-
sort.reverse.
|
17
|
-
changeset.
|
29
|
+
sort.reverse.inject({}) do |final, (_, changeset)|
|
30
|
+
changeset.merge(final)
|
18
31
|
end
|
19
32
|
end
|
20
33
|
|
data/lib/restforce/db/version.rb
CHANGED
@@ -14,6 +14,18 @@ describe Restforce::DB::Accumulator do
|
|
14
14
|
it "stores the passed changeset in the accumulator" do
|
15
15
|
expect(accumulator[timestamp]).to_equal changes
|
16
16
|
end
|
17
|
+
|
18
|
+
describe "for a pre-existing timestamp" do
|
19
|
+
let(:new_changes) { { old_fish: "New Fish" } }
|
20
|
+
|
21
|
+
before do
|
22
|
+
accumulator.store(timestamp, new_changes)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "updates the existing changeset in the accumulator" do
|
26
|
+
expect(accumulator[timestamp]).to_equal changes.merge(new_changes)
|
27
|
+
end
|
28
|
+
end
|
17
29
|
end
|
18
30
|
|
19
31
|
describe "#attributes" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restforce-db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Horner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -329,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
329
329
|
version: '0'
|
330
330
|
requirements: []
|
331
331
|
rubyforge_project:
|
332
|
-
rubygems_version: 2.4.
|
332
|
+
rubygems_version: 2.4.6
|
333
333
|
signing_key:
|
334
334
|
specification_version: 4
|
335
335
|
summary: Bind your database to Salesforce data
|