aws-record 1.0.0.pre.8 → 1.0.0.pre.9

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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aws-record.rb +11 -11
  3. data/lib/aws-record/record.rb +21 -0
  4. data/lib/aws-record/record/attribute.rb +35 -3
  5. data/lib/aws-record/record/attributes.rb +137 -16
  6. data/lib/aws-record/record/dirty_tracking.rb +48 -8
  7. data/lib/aws-record/record/item_operations.rb +96 -48
  8. data/lib/aws-record/record/marshalers/boolean_marshaler.rb +53 -0
  9. data/lib/aws-record/record/marshalers/date_marshaler.rb +61 -0
  10. data/lib/aws-record/record/marshalers/date_time_marshaler.rb +72 -0
  11. data/lib/aws-record/record/marshalers/float_marshaler.rb +52 -0
  12. data/lib/aws-record/record/marshalers/integer_marshaler.rb +52 -0
  13. data/lib/aws-record/record/marshalers/list_marshaler.rb +56 -0
  14. data/lib/aws-record/record/marshalers/map_marshaler.rb +56 -0
  15. data/lib/aws-record/record/marshalers/numeric_set_marshaler.rb +69 -0
  16. data/lib/aws-record/record/marshalers/string_marshaler.rb +52 -0
  17. data/lib/aws-record/record/marshalers/string_set_marshaler.rb +69 -0
  18. data/lib/aws-record/record/version.rb +1 -1
  19. metadata +12 -13
  20. data/lib/aws-record/record/attributes/boolean_marshaler.rb +0 -54
  21. data/lib/aws-record/record/attributes/date_marshaler.rb +0 -54
  22. data/lib/aws-record/record/attributes/date_time_marshaler.rb +0 -55
  23. data/lib/aws-record/record/attributes/float_marshaler.rb +0 -53
  24. data/lib/aws-record/record/attributes/integer_marshaler.rb +0 -53
  25. data/lib/aws-record/record/attributes/list_marshaler.rb +0 -66
  26. data/lib/aws-record/record/attributes/map_marshaler.rb +0 -66
  27. data/lib/aws-record/record/attributes/numeric_set_marshaler.rb +0 -72
  28. data/lib/aws-record/record/attributes/string_marshaler.rb +0 -60
  29. data/lib/aws-record/record/attributes/string_set_marshaler.rb +0 -70
@@ -1,54 +0,0 @@
1
- # Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not
4
- # use this file except in compliance with the License. A copy of the License is
5
- # located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is distributed on
10
- # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
- # or implied. See the License for the specific language governing permissions
12
- # and limitations under the License.
13
-
14
- require 'date'
15
-
16
- module Aws
17
- module Record
18
- module Attributes
19
- module DateMarshaler
20
-
21
- class << self
22
-
23
- def type_cast(raw_value, options = {})
24
- case raw_value
25
- when nil
26
- nil
27
- when ''
28
- nil
29
- when Date
30
- raw_value
31
- when Integer
32
- Date.parse(Time.at(raw_value).to_s) # assumed timestamp
33
- else
34
- Date.parse(raw_value.to_s) # Time, DateTime or String
35
- end
36
- end
37
-
38
- def serialize(raw_value, options = {})
39
- date = type_cast(raw_value)
40
- if date.nil?
41
- nil
42
- elsif date.is_a?(Date)
43
- date.strftime('%Y-%m-%d')
44
- else
45
- raise ArgumentError, "expected a Date value or nil, got #{date.class}"
46
- end
47
- end
48
-
49
- end
50
-
51
- end
52
- end
53
- end
54
- end
@@ -1,55 +0,0 @@
1
- # Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not
4
- # use this file except in compliance with the License. A copy of the License is
5
- # located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is distributed on
10
- # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
- # or implied. See the License for the specific language governing permissions
12
- # and limitations under the License.
13
-
14
- require 'date'
15
-
16
- module Aws
17
- module Record
18
- module Attributes
19
- module DateTimeMarshaler
20
-
21
- class << self
22
-
23
- def type_cast(raw_value, options = {})
24
- case raw_value
25
- when nil
26
- nil
27
- when ''
28
- nil
29
- when DateTime
30
- raw_value
31
- when Integer
32
- DateTime.parse(Time.at(raw_value).to_s) # timestamp
33
- else
34
- DateTime.parse(raw_value.to_s) # Time, Date or String
35
- end
36
- end
37
-
38
- def serialize(raw_value, options = {})
39
- datetime = type_cast(raw_value)
40
- if datetime.nil?
41
- nil
42
- elsif datetime.is_a?(DateTime)
43
- datetime.strftime('%Y-%m-%dT%H:%M:%S%Z')
44
- else
45
- msg = "expected a DateTime value or nil, got #{datetime.class}"
46
- raise ArgumentError, msg
47
- end
48
- end
49
-
50
- end
51
-
52
- end
53
- end
54
- end
55
- end
@@ -1,53 +0,0 @@
1
- # Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not
4
- # use this file except in compliance with the License. A copy of the License is
5
- # located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is distributed on
10
- # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
- # or implied. See the License for the specific language governing permissions
12
- # and limitations under the License.
13
-
14
- module Aws
15
- module Record
16
- module Attributes
17
- module FloatMarshaler
18
-
19
- class << self
20
-
21
- def type_cast(raw_value, options = {})
22
- case raw_value
23
- when nil
24
- nil
25
- when ''
26
- nil
27
- when Float
28
- raw_value
29
- else
30
- raw_value.respond_to?(:to_f) ?
31
- raw_value.to_f :
32
- raw_value.to_s.to_f
33
- end
34
- end
35
-
36
- def serialize(raw_value, options = {})
37
- float = type_cast(raw_value, options = {})
38
- if float.nil?
39
- nil
40
- elsif float.is_a?(Float)
41
- float
42
- else
43
- msg = "expected a Float value or nil, got #{float.class}"
44
- raise ArgumentError, msg
45
- end
46
- end
47
-
48
- end
49
-
50
- end
51
- end
52
- end
53
- end
@@ -1,53 +0,0 @@
1
- # Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not
4
- # use this file except in compliance with the License. A copy of the License is
5
- # located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is distributed on
10
- # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
- # or implied. See the License for the specific language governing permissions
12
- # and limitations under the License.
13
-
14
- module Aws
15
- module Record
16
- module Attributes
17
- module IntegerMarshaler
18
-
19
- class << self
20
-
21
- def type_cast(raw_value, options = {})
22
- case raw_value
23
- when nil
24
- nil
25
- when ''
26
- nil
27
- when Integer
28
- raw_value
29
- else
30
- raw_value.respond_to?(:to_i) ?
31
- raw_value.to_i :
32
- raw_value.to_s.to_i
33
- end
34
- end
35
-
36
- def serialize(raw_value, options = {})
37
- integer = type_cast(raw_value, options = {})
38
- if integer.nil?
39
- nil
40
- elsif integer.is_a?(Integer)
41
- integer
42
- else
43
- msg = "expected an Integer value or nil, got #{integer.class}"
44
- raise ArgumentError, msg
45
- end
46
- end
47
-
48
- end
49
-
50
- end
51
- end
52
- end
53
- end
@@ -1,66 +0,0 @@
1
- # Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not
4
- # use this file except in compliance with the License. A copy of the License is
5
- # located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is distributed on
10
- # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
- # or implied. See the License for the specific language governing permissions
12
- # and limitations under the License.
13
-
14
- module Aws
15
- module Record
16
- module Attributes
17
- module ListMarshaler
18
-
19
- class << self
20
-
21
- def type_cast(raw_value, options = {})
22
- case raw_value
23
- when nil
24
- _cast_nil(raw_value, options)
25
- when ''
26
- _cast_nil(raw_value, options)
27
- when Array
28
- raw_value
29
- else
30
- if raw_value.respond_to?(:to_a)
31
- raw_value.to_a
32
- else
33
- msg = "Don't know how to make #{raw_value} of type"\
34
- " #{raw_value.class} into an array!"
35
- raise ArgumentError, msg
36
- end
37
- end
38
- end
39
-
40
- def serialize(raw_value, options = {})
41
- list = type_cast(raw_value, options)
42
- if list.is_a?(Array)
43
- list
44
- elsif list.nil?
45
- nil
46
- else
47
- msg = "expected an Array value or nil, got #{list.class}"
48
- raise ArgumentError, msg
49
- end
50
- end
51
-
52
- private
53
- def _cast_nil(raw_value, options)
54
- if options[:nil_as_empty_list]
55
- []
56
- else
57
- nil
58
- end
59
- end
60
-
61
- end
62
-
63
- end
64
- end
65
- end
66
- end
@@ -1,66 +0,0 @@
1
- # Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not
4
- # use this file except in compliance with the License. A copy of the License is
5
- # located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is distributed on
10
- # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
- # or implied. See the License for the specific language governing permissions
12
- # and limitations under the License.
13
-
14
- module Aws
15
- module Record
16
- module Attributes
17
- module MapMarshaler
18
-
19
- class << self
20
-
21
- def type_cast(raw_value, options = {})
22
- case raw_value
23
- when nil
24
- _cast_nil(raw_value, options)
25
- when ''
26
- _cast_nil(raw_value, options)
27
- when Hash
28
- raw_value
29
- else
30
- if raw_value.respond_to?(:to_h)
31
- raw_value.to_h
32
- else
33
- msg = "Don't know how to make #{raw_value} of type"\
34
- " #{raw_value.class} into a hash!"
35
- raise ArgumentError, msg
36
- end
37
- end
38
- end
39
-
40
- def serialize(raw_value, options = {})
41
- map = type_cast(raw_value, options)
42
- if map.is_a?(Hash)
43
- map
44
- elsif map.nil?
45
- nil
46
- else
47
- msg = "expected a Hash value or nil, got #{map.class}"
48
- raise ArgumentError, msg
49
- end
50
- end
51
-
52
- private
53
- def _cast_nil(raw_value, options)
54
- if options[:nil_as_empty_map]
55
- {}
56
- else
57
- nil
58
- end
59
- end
60
-
61
- end
62
-
63
- end
64
- end
65
- end
66
- end
@@ -1,72 +0,0 @@
1
- # Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not
4
- # use this file except in compliance with the License. A copy of the License is
5
- # located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is distributed on
10
- # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
- # or implied. See the License for the specific language governing permissions
12
- # and limitations under the License.
13
-
14
- require 'bigdecimal'
15
-
16
- module Aws
17
- module Record
18
- module Attributes
19
- module NumericSetMarshaler
20
-
21
- class << self
22
-
23
- def type_cast(raw_value, options = {})
24
- case raw_value
25
- when nil
26
- Set.new
27
- when ''
28
- Set.new
29
- when Set
30
- _as_numeric(raw_value)
31
- else
32
- if raw_value.respond_to?(:to_set)
33
- _as_numeric(raw_value.to_set)
34
- else
35
- msg = "Don't know how to make #{raw_value} of type"\
36
- " #{raw_value.class} into a Numeric Set!"
37
- raise ArgumentError, msg
38
- end
39
- end
40
- end
41
-
42
- def serialize(raw_value, options = {})
43
- set = type_cast(raw_value, options)
44
- if set.is_a?(Set)
45
- if set.empty?
46
- nil
47
- else
48
- set
49
- end
50
- else
51
- msg = "expected a Set value or nil, got #{set.class}"
52
- raise ArgumentError, msg
53
- end
54
- end
55
-
56
- private
57
- def _as_numeric(set)
58
- set.collect! do |item|
59
- if item.is_a?(Numeric)
60
- item
61
- else
62
- BigDecimal.new(item.to_s)
63
- end
64
- end
65
- end
66
-
67
- end
68
-
69
- end
70
- end
71
- end
72
- end
@@ -1,60 +0,0 @@
1
- # Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not
4
- # use this file except in compliance with the License. A copy of the License is
5
- # located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is distributed on
10
- # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
- # or implied. See the License for the specific language governing permissions
12
- # and limitations under the License.
13
-
14
- module Aws
15
- module Record
16
- module Attributes
17
- module StringMarshaler
18
-
19
- class << self
20
-
21
- def type_cast(raw_value, options = {})
22
- case raw_value
23
- when nil
24
- if options[:nil_as_empty_string]
25
- ''
26
- else
27
- nil
28
- end
29
- when String
30
- if raw_value.empty? && !options[:nil_as_empty_string]
31
- nil
32
- else
33
- raw_value
34
- end
35
- else
36
- raw_value.to_s
37
- end
38
- end
39
-
40
- def serialize(raw_value, options = {})
41
- value = type_cast(raw_value)
42
- if value.is_a?(String)
43
- if value.empty?
44
- nil
45
- else
46
- value
47
- end
48
- elsif value.nil?
49
- nil
50
- else
51
- msg = "expected a String value or nil, got #{value.class}"
52
- raise ArgumentError, msg
53
- end
54
- end
55
-
56
- end
57
- end
58
- end
59
- end
60
- end