aws-record 1.1.0 → 1.1.1

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: 707c0dda4d338ec8c39441124f050922181ca6a5
4
- data.tar.gz: 945f67f08fa5230b7c3f7dac7d95138a1017ee9c
3
+ metadata.gz: 00556892b995d898a18d635efe0ed54b68eef8aa
4
+ data.tar.gz: 3b4e23507a6b8807f6858724d2b5f506bbe8d52c
5
5
  SHA512:
6
- metadata.gz: f58be26c4c9c1215a293fbbcc1484ca4993d305edeac7e16182df127a9fe80620135024039190eb9894d3ed5f58554a02cf93cd091b73c9b133c7c739d4a90ba
7
- data.tar.gz: 056e886c4d5146019525d9aa5eb25e2f4e195dfee69abf9105be266210ca6e20daee3f0b5a3be66ab390d30d5eb7506e83ac0cd0842e62242fd602ce3f0d5ce0
6
+ metadata.gz: d5412fe360df00866112c349095353dc5222f3768677883d2d878a9951f556f914a81d64a22cef8cb2989e6953200c03bf19130bea4063aa3ef3b02d46643ab6
7
+ data.tar.gz: 7fdc9438de9bf7b5d0f69d028c9630efc3710b83a3dcce92db33c099d7a6a0de4b963c1e5150792e5897ee13335e35d019f5f1897339e4115bb66b9f100b6d85
@@ -21,7 +21,7 @@ module Aws
21
21
  # within the model class and item instances.
22
22
  class Attribute
23
23
 
24
- attr_reader :name, :database_name, :dynamodb_type, :default_value
24
+ attr_reader :name, :database_name, :dynamodb_type
25
25
 
26
26
  # @param [Symbol] name Name of the attribute. It should be a name that is
27
27
  # safe to use as a method.
@@ -53,7 +53,7 @@ module Aws
53
53
  @marshaler = options[:marshaler] || DefaultMarshaler
54
54
  @persist_nil = options[:persist_nil]
55
55
  dv = options[:default_value]
56
- @default_value = type_cast(dv) unless dv.nil?
56
+ @default_value_or_lambda = type_cast(dv) unless dv.nil?
57
57
  end
58
58
 
59
59
  # Attempts to type cast a raw value into the attribute's type. This call
@@ -90,6 +90,20 @@ module Aws
90
90
  dynamodb_item[@database_name]
91
91
  end
92
92
 
93
+ # @api private
94
+ def default_value
95
+ if @default_value_or_lambda.respond_to?(:call)
96
+ @default_value_or_lambda.call
97
+ else
98
+ _deep_copy(@default_value_or_lambda)
99
+ end
100
+ end
101
+
102
+ private
103
+ def _deep_copy(obj)
104
+ Marshal.load(Marshal.dump(obj))
105
+ end
106
+
93
107
  end
94
108
 
95
109
  # This is an identity marshaler, which performs no changes for type casting
@@ -23,6 +23,7 @@ module Aws
23
23
  @model_attributes = model_attributes
24
24
  @track_mutations = opts[:track_mutations]
25
25
  @track_mutations = true if opts[:track_mutations].nil?
26
+ populate_default_values
26
27
  end
27
28
 
28
29
  def get_attribute(name)
@@ -13,6 +13,6 @@
13
13
 
14
14
  module Aws
15
15
  module Record
16
- VERSION = '1.1.0'
16
+ VERSION = '1.1.1'
17
17
  end
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-21 00:00:00.000000000 Z
11
+ date: 2017-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-resources