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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a025c678317bce959cb08e9fe84d43e17ee8b0f
4
- data.tar.gz: 408402f20f9a9e9e523039df3e43114732aa013a
3
+ metadata.gz: ff045872089e14d4c15edd81e9c56e130b687a4a
4
+ data.tar.gz: 81ccba24839284cbe2f7ebbdfdcf8f36464da6ea
5
5
  SHA512:
6
- metadata.gz: 0863ca668599f711306a9a0c144a52b69f0e42f89b4b6397a86797a13fb5111c2f0b52346627ec59bab791707e4dd6c7fd9865f081706c4cd69de4e418da3f2b
7
- data.tar.gz: 17ea2d92690e352a795bb6ccc23fb5cfecc6b7422cc6af583f12f5bb663d85baedf00e3c35d674455d4f602ed5e4a865d5b7e548635982b89c923666fb499239
6
+ metadata.gz: 95b0a633370cb62a104c3aaf1b89827ac2d358985bfaa8ea7dcc907c2773510d0e0b8a5d9fbd1b62ad81f0628b2530708aba4a453b24a17da9363ba5ce86bd9f
7
+ data.tar.gz: 59ce8f857ba15a05a1489716f7d88d99b32aa8ec88606192e0da05859484bf501849abb634c8891cff757a48c44b36abfb4b895fd8f30d4995861ddc18817b7b
@@ -1,3 +1,8 @@
1
+ v0.1.3
2
+ ------
3
+
4
+ * Fix coercer to preserve nil attributes
5
+
1
6
  v0.1.2
2
7
  ------
3
8
 
@@ -3,6 +3,6 @@ module Lotus
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '0.1.2'
6
+ VERSION = '0.1.3'
7
7
  end
8
8
  end
@@ -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
@@ -2,6 +2,6 @@ require 'test_helper'
2
2
 
3
3
  describe Lotus::Dynamodb::VERSION do
4
4
  it 'returns current version' do
5
- Lotus::Dynamodb::VERSION.must_equal '0.1.2'
5
+ Lotus::Dynamodb::VERSION.must_equal '0.1.3'
6
6
  end
7
7
  end
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.2
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-04 00:00:00.000000000 Z
11
+ date: 2014-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lotus-model