dynamini 2.10.0 → 2.10.1

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: 550e30d31da4f4477173bed3f3bfdc2e2f2737c5
4
- data.tar.gz: 0409ad955e8eaf774ae88a7fc489711df4dd2b31
3
+ metadata.gz: 7666f36d72a5a8cd120410d8d1f915d79ca61d50
4
+ data.tar.gz: cb3c42f63ecb17bbfc877f534829ee8b915e3fb5
5
5
  SHA512:
6
- metadata.gz: 86ac879bf7cc6a68eb67f29206588e3ede7a5c47b548b6413a26a9d2c6b50a37118b078d5b0e96b63a5a1f9111bf358a9a5bccc70c3afadcfa6c1673d9d6319b
7
- data.tar.gz: 2a68e39f0478eb078bd53fc30544c112c340011188fd3d2cde79c3118a4f45ee438f127e9044c7ec31e770e795ae2f1490ca2384540f8cd2ff3dc77d5da1d9fe
6
+ metadata.gz: fdc3861dca2bb1a7c2253b188e70023bffbc90cfc12c8c35f5fadc8b7bf1a382ed4e9619051526e321f28e82fbed062f9d14b74d3f9eb7c6c02d73466289f751
7
+ data.tar.gz: 090851dfcd7df23511dc98800d3946de5e6133520128953c81980fa545da3f256927ef88a39c491bdca7baebd5e236c4c4cecfdcf47639b415dda9940d93d89a
data/README.md CHANGED
@@ -134,6 +134,8 @@ Default values aren't actually written to the database when saving your instance
134
134
 
135
135
  The auto-generated fields updated_at and created_at are intrinsically handled as :time.
136
136
 
137
+ If you want to see all your attributes at once, with type conversions applied (e.g for serialization as JSON), call :handled_attributes. The :attributes method, conversely, will show you the real values as written to DynamoDB.
138
+
137
139
  ## Enumerable Attributes
138
140
  You can save arrays and sets to your Dynamini model. Optionally, you can have Dynamini perform type conversion on each element of your enumerable. Here's how it works:
139
141
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dynamini'
3
- s.version = '2.10.0'
3
+ s.version = '2.10.1'
4
4
  s.summary = 'DynamoDB interface'
5
5
  s.description = 'Lightweight DynamoDB interface gem designed as
6
6
  a drop-in replacement for ActiveRecord.
@@ -28,9 +28,11 @@ module Dynamini
28
28
  end
29
29
 
30
30
  def batch_delete(ids)
31
- requests = ids.map{|id| { delete_request: { key: { hash_key => id } } } }
32
- options = { request_items: { table_name => requests } }
33
- client.batch_write_item(options)
31
+ deletes = ids.map{ |id| { delete_request: { key: { hash_key => id } } } }
32
+
33
+ deletes.each_slice(25) do |slice|
34
+ client.batch_write_item(request_items: { table_name => slice })
35
+ end
34
36
  end
35
37
 
36
38
  def scan(options = {})
@@ -88,13 +88,12 @@ describe Dynamini::BatchOperations do
88
88
 
89
89
  context 'when requesting over 100 items' do
90
90
  let(:ids) do
91
- i =* (1..101)
91
+ i = *(1..101)
92
92
  i.map(&:to_s)
93
93
  end
94
94
 
95
95
  before do
96
- i =* (1..51)
97
- i.each { |id| Dynamini::Base.create(id: id.to_s) }
96
+ 51.times { |i| Dynamini::Base.create(id: (i + 1).to_s) }
98
97
  end
99
98
 
100
99
  it 'should call dynamo once for each 100 items' do
@@ -119,11 +118,29 @@ describe Dynamini::BatchOperations do
119
118
  Dynamini::Base.create(id: '7890')
120
119
  end
121
120
 
122
- it 'should delete all items in collection to the database' do
123
- subject.batch_delete(ids)
124
- expect{ Dynamini::Base.find('4321') }.to raise_error(Dynamini::RecordNotFound)
125
- expect{ Dynamini::Base.find('4567') }.to raise_error(Dynamini::RecordNotFound)
126
- expect{ Dynamini::Base.find('7890') }.to raise_error(Dynamini::RecordNotFound)
121
+ context 'when deleting the max length or under' do
122
+ it 'should delete all items in collection to the database' do
123
+ subject.batch_delete(ids)
124
+ expect{ Dynamini::Base.find('4321') }.to raise_error(Dynamini::RecordNotFound)
125
+ expect{ Dynamini::Base.find('4567') }.to raise_error(Dynamini::RecordNotFound)
126
+ expect{ Dynamini::Base.find('7890') }.to raise_error(Dynamini::RecordNotFound)
127
+ end
128
+ end
129
+
130
+ context 'when deleting more than the max length' do
131
+ let (:ids) do
132
+ [
133
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4321, 17, 18, 19, 20, 4567, 22, 23, 24, 25,
134
+ 26, 7890
135
+ ].map{ |id| id.to_s }
136
+ end
137
+ it 'invokes the client with each slice' do
138
+ expect(Dynamini::Base.client).to receive(:batch_write_item).twice.and_call_original
139
+ subject.batch_delete(ids)
140
+ expect{ Dynamini::Base.find('4321') }.to raise_error(Dynamini::RecordNotFound)
141
+ expect{ Dynamini::Base.find('4567') }.to raise_error(Dynamini::RecordNotFound)
142
+ expect{ Dynamini::Base.find('7890') }.to raise_error(Dynamini::RecordNotFound)
143
+ end
127
144
  end
128
145
  end
129
146
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamini
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Ward
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2017-09-18 00:00:00.000000000 Z
18
+ date: 2017-09-19 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel