dynamini 2.7.8 → 2.8.0

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: 01ea8a754a012517d0bf7afbee76a77a450b9ac0
4
- data.tar.gz: c1c776b9840febccb67de36ed21488ba2f870c1d
3
+ metadata.gz: e236f8c8534a981275e1f4e6f92fea37fbdad844
4
+ data.tar.gz: 1e72cb755d72e27ae30834db85a2e0f2d00e2141
5
5
  SHA512:
6
- metadata.gz: 2536bae8f8bac94a056275c7a2bc342f8eddab779f1b72181f23dca5b6f31601d71f7ebe2fb3c2be546c77c284963ae39cd531370db7a59890e43537f569071f
7
- data.tar.gz: 0d1f7f169d57f53d86fe248e6ecd8aea99f0206f0dc0caf5df717e8a2898db06eb3313db97a55dffb6b743f381bbcae78e28fc4c7cbde66b3c2c6fe11374e45d
6
+ metadata.gz: b1f37058d062d3ddc4b7ead58a23c0335cbeda994db926ca3abb2178139b7eefcbcf1a4125bce7c893575ec67197aa30f62dd32a5788afe6f8ff8194eda8ddc0
7
+ data.tar.gz: a1aeae7aaa42a1a62c5c966e5141aa9804026541613094d4f5fb6f6a05e9f6bc808c796623763ec7c9eda81a4f5ee6e57caaeb556e1f19a6956c98c0d19e8e8f
data/README.md CHANGED
@@ -198,6 +198,38 @@ DailyWeather.query(hash_key: "Toronto", scan_index_forward: false)
198
198
  > [C, B, A]
199
199
  ```
200
200
 
201
+ ## Batch Saving
202
+ Dynamo allows batch saving, see: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html
203
+
204
+ ```ruby
205
+ class Product < Dynamini::Base
206
+ set_hash_key :upc
207
+ end
208
+
209
+ model1 = Product.new({upc: 'abc', name: 'model1'})
210
+ model2 = Product.new({upc: 'xyz', name: 'model2'})
211
+
212
+ Product.import([model1, model2])
213
+
214
+ Product.find('abc').name
215
+ > 'model1'
216
+
217
+ model3 = Product.new({upc: 'qwerty', name: 'model3'}, skip_timestamps: true)
218
+
219
+ Product.import([model3], skip_timestamps: true)
220
+
221
+ Product.find('qwerty').name
222
+ > 'model3'
223
+
224
+ Product.find('qwerty').created_at
225
+ > nil
226
+
227
+ Product.find('qwerty').updated_at
228
+ > nil
229
+
230
+ ````
231
+
232
+
201
233
  ## Testing
202
234
  We've included an optional in-memory test client, so you don't necessarily have to connect to a real Dynamo instance when running tests. You could also use this in your development environment if you don't have a real Dynamo instance yet, but the data saved to it won't persist through a server restart.
203
235
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dynamini'
3
- s.version = '2.7.8'
3
+ s.version = '2.8.0'
4
4
  s.summary = 'DynamoDB interface'
5
5
  s.description = 'Lightweight DynamoDB interface gem designed as
6
6
  a drop-in replacement for ActiveRecord.
@@ -3,12 +3,12 @@ require 'ostruct'
3
3
  module Dynamini
4
4
  module BatchOperations
5
5
 
6
- def import(models)
6
+ def import(models, options = {})
7
7
  # Max batch size is 25, per Dynamo BatchWriteItem docs
8
8
 
9
9
  models.each_slice(25) do |batch|
10
10
  batch.each do |model|
11
- model.send(:generate_timestamps!)
11
+ model.send(:generate_timestamps!) unless options[:skip_timestamps]
12
12
  end
13
13
  dynamo_batch_save(batch)
14
14
  end
@@ -28,6 +28,18 @@ describe Dynamini::BatchOperations do
28
28
  expect(subject.find(model2.id).created_at).not_to be_nil
29
29
  end
30
30
 
31
+ it 'should not generate timestamps if skip_timestamp flag is passed' do
32
+ model1 = Dynamini::Base.new(model_attributes)
33
+ model2 = Dynamini::Base.new(model_attributes.merge(id: '2'))
34
+
35
+ subject.import([model1, model2], skip_timestamps: true)
36
+
37
+ expect(subject.find(model1.id).updated_at).to be_nil
38
+ expect(subject.find(model1.id).created_at).to be_nil
39
+ expect(subject.find(model2.id).updated_at).to be_nil
40
+ expect(subject.find(model2.id).created_at).to be_nil
41
+ end
42
+
31
43
  it 'should call .dynamo_batch_save with batches of 25 models' do
32
44
  models = Array.new(30, model)
33
45
  expect(subject).to receive(:dynamo_batch_save).with(array_including(models[0..24])).ordered
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.7.8
4
+ version: 2.8.0
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-02-27 00:00:00.000000000 Z
18
+ date: 2017-08-10 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel
@@ -140,7 +140,6 @@ files:
140
140
  - README.md
141
141
  - Rakefile
142
142
  - dynamini.gemspec
143
- - lib/.DS_Store
144
143
  - lib/dynamini.rb
145
144
  - lib/dynamini/attributes.rb
146
145
  - lib/dynamini/base.rb
@@ -185,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
184
  version: '0'
186
185
  requirements: []
187
186
  rubyforge_project:
188
- rubygems_version: 2.5.1
187
+ rubygems_version: 2.6.12
189
188
  signing_key:
190
189
  specification_version: 4
191
190
  summary: DynamoDB interface