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
@@ -0,0 +1,52 @@
1
+ # Copyright 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 Marshalers
17
+
18
+ class IntegerMarshaler
19
+ def initialize(opts = {})
20
+ end
21
+
22
+ def type_cast(raw_value)
23
+ case raw_value
24
+ when nil
25
+ nil
26
+ when ''
27
+ nil
28
+ when Integer
29
+ raw_value
30
+ else
31
+ raw_value.respond_to?(:to_i) ?
32
+ raw_value.to_i :
33
+ raw_value.to_s.to_i
34
+ end
35
+ end
36
+
37
+ def serialize(raw_value)
38
+ integer = type_cast(raw_value)
39
+ if integer.nil?
40
+ nil
41
+ elsif integer.is_a?(Integer)
42
+ integer
43
+ else
44
+ msg = "expected an Integer value or nil, got #{integer.class}"
45
+ raise ArgumentError, msg
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,56 @@
1
+ # Copyright 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 Marshalers
17
+
18
+ class ListMarshaler
19
+ def initialize(opts = {})
20
+ end
21
+
22
+ def type_cast(raw_value)
23
+ case raw_value
24
+ when nil
25
+ nil
26
+ when ''
27
+ nil
28
+ when Array
29
+ raw_value
30
+ else
31
+ if raw_value.respond_to?(:to_a)
32
+ raw_value.to_a
33
+ else
34
+ msg = "Don't know how to make #{raw_value} of type"\
35
+ " #{raw_value.class} into an array!"
36
+ raise ArgumentError, msg
37
+ end
38
+ end
39
+ end
40
+
41
+ def serialize(raw_value)
42
+ list = type_cast(raw_value)
43
+ if list.is_a?(Array)
44
+ list
45
+ elsif list.nil?
46
+ nil
47
+ else
48
+ msg = "expected an Array value or nil, got #{list.class}"
49
+ raise ArgumentError, msg
50
+ end
51
+ end
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ # Copyright 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 Marshalers
17
+
18
+ class MapMarshaler
19
+ def initialize(opts = {})
20
+ end
21
+
22
+ def type_cast(raw_value)
23
+ case raw_value
24
+ when nil
25
+ nil
26
+ when ''
27
+ nil
28
+ when Hash
29
+ raw_value
30
+ else
31
+ if raw_value.respond_to?(:to_h)
32
+ raw_value.to_h
33
+ else
34
+ msg = "Don't know how to make #{raw_value} of type"\
35
+ " #{raw_value.class} into a hash!"
36
+ raise ArgumentError, msg
37
+ end
38
+ end
39
+ end
40
+
41
+ def serialize(raw_value)
42
+ map = type_cast(raw_value)
43
+ if map.is_a?(Hash)
44
+ map
45
+ elsif map.nil?
46
+ nil
47
+ else
48
+ msg = "expected a Hash value or nil, got #{map.class}"
49
+ raise ArgumentError, msg
50
+ end
51
+ end
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,69 @@
1
+ # Copyright 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 Marshalers
17
+
18
+ class NumericSetMarshaler
19
+ def initialize(opts = {})
20
+ end
21
+
22
+ def type_cast(raw_value)
23
+ case raw_value
24
+ when nil
25
+ Set.new
26
+ when ''
27
+ Set.new
28
+ when Set
29
+ _as_numeric(raw_value)
30
+ else
31
+ if raw_value.respond_to?(:to_set)
32
+ _as_numeric(raw_value.to_set)
33
+ else
34
+ msg = "Don't know how to make #{raw_value} of type"\
35
+ " #{raw_value.class} into a Numeric Set!"
36
+ raise ArgumentError, msg
37
+ end
38
+ end
39
+ end
40
+
41
+ def serialize(raw_value)
42
+ set = type_cast(raw_value)
43
+ if set.is_a?(Set)
44
+ if set.empty?
45
+ nil
46
+ else
47
+ set
48
+ end
49
+ else
50
+ msg = "expected a Set value or nil, got #{set.class}"
51
+ raise ArgumentError, msg
52
+ end
53
+ end
54
+
55
+ private
56
+ def _as_numeric(set)
57
+ set.collect! do |item|
58
+ if item.is_a?(Numeric)
59
+ item
60
+ else
61
+ BigDecimal.new(item.to_s)
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,52 @@
1
+ # Copyright 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 Marshalers
17
+
18
+ class StringMarshaler
19
+ def initialize(opts = {})
20
+ end
21
+
22
+ def type_cast(raw_value)
23
+ case raw_value
24
+ when nil
25
+ nil
26
+ when String
27
+ raw_value
28
+ else
29
+ raw_value.to_s
30
+ end
31
+ end
32
+
33
+ def serialize(raw_value)
34
+ value = type_cast(raw_value)
35
+ if value.is_a?(String)
36
+ if value.empty?
37
+ nil
38
+ else
39
+ value
40
+ end
41
+ elsif value.nil?
42
+ nil
43
+ else
44
+ msg = "expected a String value or nil, got #{value.class}"
45
+ raise ArgumentError, msg
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,69 @@
1
+ # Copyright 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 Marshalers
17
+
18
+ class StringSetMarshaler
19
+ def initialize(opts = {})
20
+ end
21
+
22
+ def type_cast(raw_value)
23
+ case raw_value
24
+ when nil
25
+ Set.new
26
+ when ''
27
+ Set.new
28
+ when Set
29
+ _as_strings(raw_value)
30
+ else
31
+ if raw_value.respond_to?(:to_set)
32
+ _as_strings(raw_value.to_set)
33
+ else
34
+ msg = "Don't know how to make #{raw_value} of type"\
35
+ " #{raw_value.class} into a String Set!"
36
+ raise ArgumentError, msg
37
+ end
38
+ end
39
+ end
40
+
41
+ def serialize(raw_value)
42
+ set = type_cast(raw_value)
43
+ if set.is_a?(Set)
44
+ if set.empty?
45
+ nil
46
+ else
47
+ set
48
+ end
49
+ else
50
+ msg = "expected a Set value or nil, got #{set.class}"
51
+ raise ArgumentError, msg
52
+ end
53
+ end
54
+
55
+ private
56
+ def _as_strings(set)
57
+ set.collect! do |item|
58
+ if item.is_a?(String)
59
+ item
60
+ else
61
+ item.to_s
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -13,6 +13,6 @@
13
13
 
14
14
  module Aws
15
15
  module Record
16
- VERSION = '1.0.0.pre.8'
16
+ VERSION = '1.0.0.pre.9'
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.0.0.pre.8
4
+ version: 1.0.0.pre.9
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: 2016-05-19 00:00:00.000000000 Z
11
+ date: 2016-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-resources
@@ -35,20 +35,20 @@ files:
35
35
  - lib/aws-record/record.rb
36
36
  - lib/aws-record/record/attribute.rb
37
37
  - lib/aws-record/record/attributes.rb
38
- - lib/aws-record/record/attributes/boolean_marshaler.rb
39
- - lib/aws-record/record/attributes/date_marshaler.rb
40
- - lib/aws-record/record/attributes/date_time_marshaler.rb
41
- - lib/aws-record/record/attributes/float_marshaler.rb
42
- - lib/aws-record/record/attributes/integer_marshaler.rb
43
- - lib/aws-record/record/attributes/list_marshaler.rb
44
- - lib/aws-record/record/attributes/map_marshaler.rb
45
- - lib/aws-record/record/attributes/numeric_set_marshaler.rb
46
- - lib/aws-record/record/attributes/string_marshaler.rb
47
- - lib/aws-record/record/attributes/string_set_marshaler.rb
48
38
  - lib/aws-record/record/dirty_tracking.rb
49
39
  - lib/aws-record/record/errors.rb
50
40
  - lib/aws-record/record/item_collection.rb
51
41
  - lib/aws-record/record/item_operations.rb
42
+ - lib/aws-record/record/marshalers/boolean_marshaler.rb
43
+ - lib/aws-record/record/marshalers/date_marshaler.rb
44
+ - lib/aws-record/record/marshalers/date_time_marshaler.rb
45
+ - lib/aws-record/record/marshalers/float_marshaler.rb
46
+ - lib/aws-record/record/marshalers/integer_marshaler.rb
47
+ - lib/aws-record/record/marshalers/list_marshaler.rb
48
+ - lib/aws-record/record/marshalers/map_marshaler.rb
49
+ - lib/aws-record/record/marshalers/numeric_set_marshaler.rb
50
+ - lib/aws-record/record/marshalers/string_marshaler.rb
51
+ - lib/aws-record/record/marshalers/string_set_marshaler.rb
52
52
  - lib/aws-record/record/query.rb
53
53
  - lib/aws-record/record/secondary_indexes.rb
54
54
  - lib/aws-record/record/table_migration.rb
@@ -78,4 +78,3 @@ signing_key:
78
78
  specification_version: 4
79
79
  summary: AWS Record library for Amazon DynamoDB
80
80
  test_files: []
81
- has_rdoc:
@@ -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
- module Aws
15
- module Record
16
- module Attributes
17
- module BooleanMarshaler
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 false, 'false', '0', 0
28
- false
29
- else
30
- true
31
- end
32
- end
33
-
34
- def serialize(raw_value, options = {})
35
- boolean = type_cast(raw_value, options)
36
- case boolean
37
- when nil
38
- nil
39
- when false
40
- false
41
- when true
42
- true
43
- else
44
- msg = "expected a boolean value or nil, got #{boolean.class}"
45
- raise ArgumentError, msg
46
- end
47
- end
48
-
49
- end
50
-
51
- end
52
- end
53
- end
54
- end