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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a496ab94797e0112018c905936d04e042dead0a1
4
- data.tar.gz: d34840c6422fd7bbd249e5e1004b2fbb7619ed72
3
+ metadata.gz: f57de6493c226fdecb4aebeb48f19da412745684
4
+ data.tar.gz: f8d324ad1c4f064666f8ccb5dd85b5a96312f77e
5
5
  SHA512:
6
- metadata.gz: a67f699ce593ca14db62a83e9c006eb5f462b914f0639cf61c898b593db6b6f4e43591f40b7b7681e6960c9a437c9302188d5911bc62495a2460e1a0fc734d96
7
- data.tar.gz: 07b96b1f71c8c3713a2cde8260050a1dd58f2fbb1319b5214e984c6b298355d09bb6f02f2b6394d56296d0b1cab5877b9e38332bd43e121fb64f5316027da7af
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
@@ -1,3 +1,3 @@
1
1
  module DynamoRecord
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  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.8
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-06 00:00:00.000000000 Z
11
+ date: 2015-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport