dynamo_record 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dynamo_record/document.rb +3 -2
- data/lib/dynamo_record/version.rb +1 -1
- data/spec/dynamo_record/document_spec.rb +8 -0
- 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: f57de6493c226fdecb4aebeb48f19da412745684
|
4
|
+
data.tar.gz: f8d324ad1c4f064666f8ccb5dd85b5a96312f77e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 482813d0e3c551b46c46e218d1a49de64696f6d4f6aaf4cc32fb60bbc5776148fd18e6b6e18339052bcdc5f78820546ef7d86d4996c96ab0ad5553b2a204c491
|
7
|
+
data.tar.gz: 09ad993078b5e5e5f7d21048754d2b881f9c989e906fbac2eefd4370886e3fb6459876ab8341941d775d946d30d480f42ae54114895338102acea933e06e020a
|
@@ -13,13 +13,13 @@ module DynamoRecord
|
|
13
13
|
|
14
14
|
module ClassMethods
|
15
15
|
def from_database(attrs)
|
16
|
-
self.new(attrs).tap { |r| r.new_record = false}
|
16
|
+
self.new(attrs, true).tap { |r| r.new_record = false}
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
attr_accessor :new_record, :attributes
|
21
21
|
|
22
|
-
def initialize(attrs = {})
|
22
|
+
def initialize(attrs = {}, ignore_unknown_field = false)
|
23
23
|
@new_record = true
|
24
24
|
@attributes = {}
|
25
25
|
|
@@ -29,6 +29,7 @@ module DynamoRecord
|
|
29
29
|
end
|
30
30
|
|
31
31
|
attrs.each do |key, value|
|
32
|
+
next if ignore_unknown_field && !respond_to?("#{key}=")
|
32
33
|
send("#{key}=", value)
|
33
34
|
end
|
34
35
|
end
|
@@ -16,4 +16,12 @@ RSpec.describe DynamoRecord::Document do
|
|
16
16
|
expect(person.new_record).to be_falsy
|
17
17
|
end
|
18
18
|
|
19
|
+
it 'raises error on unknown field' do
|
20
|
+
expect{Person.new({unknown_field: 'unknown'})}.to raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'can ignore unknown field' do
|
24
|
+
expect{Person.new({unknown_field: 'unknown'}, true)}.to_not raise_error
|
25
|
+
end
|
26
|
+
|
19
27
|
end
|
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.
|
4
|
+
version: 0.0.9
|
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-
|
11
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|