lotus-dynamodb 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/lotus/dynamodb/version.rb +1 -1
- data/lib/lotus/model/adapters/dynamodb/coercer.rb +12 -0
- data/test/model/adapters/dynamodb_adapter_test.rb +15 -1
- data/test/version_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff045872089e14d4c15edd81e9c56e130b687a4a
|
4
|
+
data.tar.gz: 81ccba24839284cbe2f7ebbdfdcf8f36464da6ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95b0a633370cb62a104c3aaf1b89827ac2d358985bfaa8ea7dcc907c2773510d0e0b8a5d9fbd1b62ad81f0628b2530708aba4a453b24a17da9363ba5ce86bd9f
|
7
|
+
data.tar.gz: 59ce8f857ba15a05a1489716f7d88d99b32aa8ec88606192e0da05859484bf501849abb634c8891cff757a48c44b36abfb4b895fd8f30d4995861ddc18817b7b
|
data/CHANGELOG.md
CHANGED
@@ -29,6 +29,7 @@ module Lotus
|
|
29
29
|
# @api private
|
30
30
|
# @since 0.1.0
|
31
31
|
def from_array(value)
|
32
|
+
return if value.nil?
|
32
33
|
_serialize(value)
|
33
34
|
end
|
34
35
|
|
@@ -37,6 +38,7 @@ module Lotus
|
|
37
38
|
# @api private
|
38
39
|
# @since 0.1.0
|
39
40
|
def to_array(value)
|
41
|
+
return if value.nil?
|
40
42
|
_deserialize(value)
|
41
43
|
end
|
42
44
|
|
@@ -45,6 +47,7 @@ module Lotus
|
|
45
47
|
# @api private
|
46
48
|
# @since 0.1.0
|
47
49
|
def from_boolean(value)
|
50
|
+
return if value.nil?
|
48
51
|
value ? 1 : 0
|
49
52
|
end
|
50
53
|
|
@@ -53,6 +56,7 @@ module Lotus
|
|
53
56
|
# @api private
|
54
57
|
# @since 0.1.0
|
55
58
|
def to_boolean(value)
|
59
|
+
return if value.nil?
|
56
60
|
value.to_i == 1
|
57
61
|
end
|
58
62
|
|
@@ -61,6 +65,7 @@ module Lotus
|
|
61
65
|
# @api private
|
62
66
|
# @since 0.1.0
|
63
67
|
def from_date(value)
|
68
|
+
return if value.nil?
|
64
69
|
value.to_time.to_i
|
65
70
|
end
|
66
71
|
|
@@ -69,6 +74,7 @@ module Lotus
|
|
69
74
|
# @api private
|
70
75
|
# @since 0.1.0
|
71
76
|
def to_date(value)
|
77
|
+
return if value.nil?
|
72
78
|
Time.at(value.to_i).to_date
|
73
79
|
end
|
74
80
|
|
@@ -77,6 +83,7 @@ module Lotus
|
|
77
83
|
# @api private
|
78
84
|
# @since 0.1.0
|
79
85
|
def from_datetime(value)
|
86
|
+
return if value.nil?
|
80
87
|
value.to_time.to_f
|
81
88
|
end
|
82
89
|
|
@@ -85,6 +92,7 @@ module Lotus
|
|
85
92
|
# @api private
|
86
93
|
# @since 0.1.0
|
87
94
|
def to_datetime(value)
|
95
|
+
return if value.nil?
|
88
96
|
Time.at(value.to_f).to_datetime
|
89
97
|
end
|
90
98
|
|
@@ -93,6 +101,7 @@ module Lotus
|
|
93
101
|
# @api private
|
94
102
|
# @since 0.1.0
|
95
103
|
def from_hash(value)
|
104
|
+
return if value.nil?
|
96
105
|
_serialize(value)
|
97
106
|
end
|
98
107
|
|
@@ -101,6 +110,7 @@ module Lotus
|
|
101
110
|
# @api private
|
102
111
|
# @since 0.1.0
|
103
112
|
def to_hash(value)
|
113
|
+
return if value.nil?
|
104
114
|
_deserialize(value)
|
105
115
|
end
|
106
116
|
|
@@ -109,6 +119,7 @@ module Lotus
|
|
109
119
|
# @api private
|
110
120
|
# @since 0.1.0
|
111
121
|
def from_time(value)
|
122
|
+
return if value.nil?
|
112
123
|
value.to_f
|
113
124
|
end
|
114
125
|
|
@@ -117,6 +128,7 @@ module Lotus
|
|
117
128
|
# @api private
|
118
129
|
# @since 0.1.0
|
119
130
|
def to_time(value)
|
131
|
+
return if value.nil?
|
120
132
|
Time.at(value.to_f)
|
121
133
|
end
|
122
134
|
|
@@ -10,7 +10,7 @@ describe Lotus::Model::Adapters::DynamodbAdapter do
|
|
10
10
|
include Lotus::Entity
|
11
11
|
end
|
12
12
|
|
13
|
-
TestPurchase = Struct.new(:id, :region, :subtotal, :item_ids, :content, :created_at) do
|
13
|
+
TestPurchase = Struct.new(:id, :region, :subtotal, :item_ids, :content, :created_at, :updated_at) do
|
14
14
|
include Lotus::Entity
|
15
15
|
end
|
16
16
|
|
@@ -42,6 +42,7 @@ describe Lotus::Model::Adapters::DynamodbAdapter do
|
|
42
42
|
attribute :item_ids, Set
|
43
43
|
attribute :content, AWS::DynamoDB::Binary
|
44
44
|
attribute :created_at, Time
|
45
|
+
attribute :updated_at, Time
|
45
46
|
|
46
47
|
identity :uuid
|
47
48
|
end
|
@@ -128,6 +129,19 @@ describe Lotus::Model::Adapters::DynamodbAdapter do
|
|
128
129
|
entity.id.wont_be_nil
|
129
130
|
@adapter.find(collection, entity.id).must_equal entity
|
130
131
|
end
|
132
|
+
|
133
|
+
describe 'preserves nil attributes' do
|
134
|
+
let(:collection) { :test_purchases }
|
135
|
+
let(:entity) { TestPurchase.new(region: "europe", created_at: Time.new) }
|
136
|
+
|
137
|
+
it do
|
138
|
+
entity.updated_at.must_equal nil
|
139
|
+
@adapter.create(collection, entity)
|
140
|
+
|
141
|
+
found_entity = @adapter.find(collection, "europe", entity.created_at)
|
142
|
+
found_entity.updated_at.must_be_nil
|
143
|
+
end
|
144
|
+
end
|
131
145
|
end
|
132
146
|
|
133
147
|
describe '#update' do
|
data/test/version_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lotus-dynamodb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Krasnoukhov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lotus-model
|