dynamo_record 0.0.7 → 0.0.8

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: a42826eb931324508f21475096b5ad35850d16d3
4
- data.tar.gz: 0baaedbfc3d2b8b844ec1a977331bbf519a00e4b
3
+ metadata.gz: a496ab94797e0112018c905936d04e042dead0a1
4
+ data.tar.gz: d34840c6422fd7bbd249e5e1004b2fbb7619ed72
5
5
  SHA512:
6
- metadata.gz: b1d4e72f4b727e38f705f6f2b35190b3a437e5914b971af7a50c779becf3a963d4f2fddcaa5815260db17a84dddad036bf8579a5b2b48d9390b1baffcd5fc1e0
7
- data.tar.gz: 98cc706dc93b4b647ba8a977e77939807435403b0940c25645d10bcd630260bb424438544c910a3818bef21e52f46322f8e6ae2b7fcc220bc96a6bd0888300e0
6
+ metadata.gz: a67f699ce593ca14db62a83e9c006eb5f462b914f0639cf61c898b593db6b6f4e43591f40b7b7681e6960c9a437c9302188d5911bc62495a2460e1a0fc734d96
7
+ data.tar.gz: 07b96b1f71c8c3713a2cde8260050a1dd58f2fbb1319b5214e984c6b298355d09bb6f02f2b6394d56296d0b1cab5877b9e38332bd43e121fb64f5316027da7af
@@ -23,6 +23,11 @@ module DynamoRecord
23
23
  @new_record = true
24
24
  @attributes = {}
25
25
 
26
+ # Set default
27
+ self.class.attributes.each do |key, value|
28
+ send("#{key}=", value[:options][:default]) if value[:options][:default]
29
+ end
30
+
26
31
  attrs.each do |key, value|
27
32
  send("#{key}=", value)
28
33
  end
@@ -1,3 +1,3 @@
1
1
  module DynamoRecord
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -30,6 +30,16 @@ RSpec.describe DynamoRecord::Fields do
30
30
  name: {type: :string, options: {index: true}}})
31
31
  end
32
32
 
33
+ it 'accepts default value' do
34
+ class City
35
+ include DynamoRecord::Document
36
+
37
+ field :population, :integer, default: 0
38
+ end
39
+
40
+ expect(City.new.population).to eq(0)
41
+ end
42
+
33
43
  it 'initializes with field values' do
34
44
  person = Person.new(name: 'A person')
35
45
  expect(person.name).to eq('A person')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamo_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nguyen Vu Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-05 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport