dynamini 2.6.3 → 2.6.4
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 +4 -4
- data/Gemfile.lock +1 -1
- data/dynamini.gemspec +1 -1
- data/lib/dynamini/base.rb +1 -2
- data/lib/dynamini/errors.rb +4 -0
- data/lib/dynamini/querying.rb +9 -4
- data/spec/dynamini/base_spec.rb +1 -1
- data/spec/dynamini/batch_operations_spec.rb +3 -3
- data/spec/dynamini/querying_spec.rb +7 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeef2ffc6acac0bce16107fb9ec281db9509bcb2
|
4
|
+
data.tar.gz: c0757f84ebc577b1ea555c61ded01733acb2ee9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9fbb688330e9ad1f1c0330f6f45e0e04eff3e2a9524d99d7e3602b2e232fb548e4b5056d14862099206c6cd77a628f26bcc71008f87a8d406d45f66a8652c4f
|
7
|
+
data.tar.gz: a610af70e44ce47b7cec2c80ee927300a9537ee85f52091342888280fce09b1c829b6f8ae3f3116fe3a1903964375bc56702991d8fb13b981063e1c22e6dce90
|
data/Gemfile.lock
CHANGED
data/dynamini.gemspec
CHANGED
data/lib/dynamini/base.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative 'dirty'
|
|
5
5
|
require_relative 'increment'
|
6
6
|
require_relative 'type_handler'
|
7
7
|
require_relative 'adder'
|
8
|
+
require_relative 'errors'
|
8
9
|
|
9
10
|
module Dynamini
|
10
11
|
# Core db interface class.
|
@@ -19,7 +20,6 @@ module Dynamini
|
|
19
20
|
include Dynamini::TypeHandler
|
20
21
|
include Dynamini::Adder
|
21
22
|
|
22
|
-
|
23
23
|
attr_reader :attributes
|
24
24
|
class_attribute :handles
|
25
25
|
|
@@ -114,7 +114,6 @@ module Dynamini
|
|
114
114
|
|
115
115
|
def save!(options = {})
|
116
116
|
run_callbacks :save do
|
117
|
-
|
118
117
|
options[:validate] = true if options[:validate].nil?
|
119
118
|
|
120
119
|
unless @changes.empty?
|
data/lib/dynamini/querying.rb
CHANGED
@@ -5,13 +5,19 @@ module Dynamini
|
|
5
5
|
def find(hash_value, range_value = nil)
|
6
6
|
fail 'Range key cannot be blank.' if range_key && range_value.nil?
|
7
7
|
response = client.get_item(table_name: table_name, key: create_key_hash(hash_value, range_value))
|
8
|
-
|
8
|
+
|
9
|
+
unless response.item
|
10
|
+
error_msg = "Couldn't find #{self} with '#{hash_key}'=#{hash_value}"
|
11
|
+
error_msg += " and '#{range_key}'=#{range_value}" if range_value
|
12
|
+
raise Dynamini::RecordNotFound, error_msg
|
13
|
+
end
|
14
|
+
|
9
15
|
new(response.item.symbolize_keys, false)
|
10
16
|
end
|
11
17
|
|
12
18
|
def find_or_nil(hash_value, range_value = nil)
|
13
19
|
find(hash_value, range_value)
|
14
|
-
rescue
|
20
|
+
rescue Dynamini::RecordNotFound
|
15
21
|
nil
|
16
22
|
end
|
17
23
|
|
@@ -25,7 +31,6 @@ module Dynamini
|
|
25
31
|
def find_or_new(hash_value, range_value = nil)
|
26
32
|
validate_query_values(hash_value, range_value)
|
27
33
|
|
28
|
-
|
29
34
|
r = client.get_item(table_name: table_name, key: create_key_hash(hash_value, range_value))
|
30
35
|
if r.item
|
31
36
|
new(r.item.symbolize_keys, false)
|
@@ -108,4 +113,4 @@ module Dynamini
|
|
108
113
|
fail 'Range key cannot be blank.' if range_key && range_value.nil?
|
109
114
|
end
|
110
115
|
end
|
111
|
-
end
|
116
|
+
end
|
data/spec/dynamini/base_spec.rb
CHANGED
@@ -256,7 +256,7 @@ describe Dynamini::Base do
|
|
256
256
|
context 'when the item exists in the DB' do
|
257
257
|
it 'should delete the item and return the item' do
|
258
258
|
expect(model.delete).to eq(model)
|
259
|
-
expect { Dynamini::Base.find(model.id) }.to raise_error
|
259
|
+
expect { Dynamini::Base.find(model.id) }.to raise_error Dynamini::RecordNotFound
|
260
260
|
end
|
261
261
|
end
|
262
262
|
context 'when the item does not exist in the DB' do
|
@@ -104,9 +104,9 @@ describe Dynamini::BatchOperations do
|
|
104
104
|
|
105
105
|
it 'should delete all items in collection to the database' do
|
106
106
|
subject.batch_delete(ids)
|
107
|
-
expect{ Dynamini::Base.find('4321') }.to raise_error(
|
108
|
-
expect{ Dynamini::Base.find('4567') }.to raise_error(
|
109
|
-
expect{ Dynamini::Base.find('7890') }.to raise_error(
|
107
|
+
expect{ Dynamini::Base.find('4321') }.to raise_error(Dynamini::RecordNotFound)
|
108
|
+
expect{ Dynamini::Base.find('4567') }.to raise_error(Dynamini::RecordNotFound)
|
109
|
+
expect{ Dynamini::Base.find('7890') }.to raise_error(Dynamini::RecordNotFound)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
@@ -37,7 +37,13 @@ describe Dynamini::Querying do
|
|
37
37
|
|
38
38
|
context 'when the object does not exist' do
|
39
39
|
it 'should raise an error' do
|
40
|
-
expect
|
40
|
+
expect do
|
41
|
+
Dynamini::Base.find('1')
|
42
|
+
end.to raise_error Dynamini::RecordNotFound, "Couldn't find Dynamini::Base with 'id'=1"
|
43
|
+
|
44
|
+
expect do
|
45
|
+
TestClassWithRange.find('1', '2')
|
46
|
+
end.to raise_error Dynamini::RecordNotFound, "Couldn't find TestClassWithRange with 'foo'=1 and 'bar'=2"
|
41
47
|
end
|
42
48
|
|
43
49
|
end
|
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.6.
|
4
|
+
version: 2.6.4
|
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: 2016-09-
|
18
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activemodel
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/dynamini/client_interface.rb
|
149
149
|
- lib/dynamini/configuration.rb
|
150
150
|
- lib/dynamini/dirty.rb
|
151
|
+
- lib/dynamini/errors.rb
|
151
152
|
- lib/dynamini/global_id.rb
|
152
153
|
- lib/dynamini/increment.rb
|
153
154
|
- lib/dynamini/querying.rb
|
@@ -184,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
185
|
version: '0'
|
185
186
|
requirements: []
|
186
187
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.4.6
|
188
189
|
signing_key:
|
189
190
|
specification_version: 4
|
190
191
|
summary: DynamoDB interface
|