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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b45cedf169f50d5e0dc1ea13ba579e9d02ad440b
4
- data.tar.gz: 8f4805e1d4d1addae8c5e710432e21ef5d5f8e32
3
+ metadata.gz: a843ad27395ce855fbdd44478f7a84f19cbf612c
4
+ data.tar.gz: ddb16c66bf0df55d2b35bb6da9efbf99cde55c7a
5
5
  SHA512:
6
- metadata.gz: 97cd3dd1aef23fc71f967acbdce6bd1cd96b75fd20f89051e85df9f6a97377c45b3736c0d38255e6ba7db78ebeb14677789480f5d13f315d3d67238872f86683
7
- data.tar.gz: a410e144635242065e91e9862cf192393427b4944064591e773b5995ab5914bae116285e7b1198930f194bd42f41ef4b0e1fcb0817b6663aa6e8261a7a72f1d1
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.each_with_object({}) do |(_, changeset), final|
17
- changeset.each { |attribute, value| final[attribute] ||= value }
29
+ sort.reverse.inject({}) do |final, (_, changeset)|
30
+ changeset.merge(final)
18
31
  end
19
32
  end
20
33
 
@@ -3,7 +3,7 @@ module Restforce
3
3
  # :nodoc:
4
4
  module DB
5
5
 
6
- VERSION = "1.2.2"
6
+ VERSION = "1.2.3"
7
7
 
8
8
  end
9
9
 
@@ -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.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-20 00:00:00.000000000 Z
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.5
332
+ rubygems_version: 2.4.6
333
333
  signing_key:
334
334
  specification_version: 4
335
335
  summary: Bind your database to Salesforce data