dynamoid 3.5.0 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -4
  3. data/README.md +24 -18
  4. data/lib/dynamoid.rb +1 -0
  5. data/lib/dynamoid/adapter.rb +7 -4
  6. data/lib/dynamoid/adapter_plugin/aws_sdk_v3.rb +14 -11
  7. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/batch_get_item.rb +1 -0
  8. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/create_table.rb +8 -7
  9. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/item_updater.rb +3 -2
  10. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/middleware/backoff.rb +1 -0
  11. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/middleware/limit.rb +1 -0
  12. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/middleware/start_key.rb +1 -0
  13. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/query.rb +1 -0
  14. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/scan.rb +1 -0
  15. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb +1 -0
  16. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/until_past_table_status.rb +1 -0
  17. data/lib/dynamoid/application_time_zone.rb +1 -0
  18. data/lib/dynamoid/associations.rb +182 -19
  19. data/lib/dynamoid/associations/association.rb +4 -2
  20. data/lib/dynamoid/associations/belongs_to.rb +2 -1
  21. data/lib/dynamoid/associations/has_and_belongs_to_many.rb +2 -1
  22. data/lib/dynamoid/associations/has_many.rb +2 -1
  23. data/lib/dynamoid/associations/has_one.rb +2 -1
  24. data/lib/dynamoid/associations/many_association.rb +65 -22
  25. data/lib/dynamoid/associations/single_association.rb +28 -1
  26. data/lib/dynamoid/components.rb +1 -0
  27. data/lib/dynamoid/config.rb +3 -2
  28. data/lib/dynamoid/config/backoff_strategies/constant_backoff.rb +1 -0
  29. data/lib/dynamoid/config/backoff_strategies/exponential_backoff.rb +1 -0
  30. data/lib/dynamoid/config/options.rb +1 -0
  31. data/lib/dynamoid/criteria.rb +1 -0
  32. data/lib/dynamoid/criteria/chain.rb +353 -33
  33. data/lib/dynamoid/criteria/ignored_conditions_detector.rb +1 -0
  34. data/lib/dynamoid/criteria/key_fields_detector.rb +10 -1
  35. data/lib/dynamoid/criteria/nonexistent_fields_detector.rb +1 -0
  36. data/lib/dynamoid/criteria/overwritten_conditions_detector.rb +1 -0
  37. data/lib/dynamoid/dirty.rb +71 -16
  38. data/lib/dynamoid/document.rb +123 -42
  39. data/lib/dynamoid/dumping.rb +9 -0
  40. data/lib/dynamoid/dynamodb_time_zone.rb +1 -0
  41. data/lib/dynamoid/fields.rb +189 -16
  42. data/lib/dynamoid/finders.rb +65 -28
  43. data/lib/dynamoid/identity_map.rb +6 -0
  44. data/lib/dynamoid/indexes.rb +74 -15
  45. data/lib/dynamoid/log/formatter.rb +26 -0
  46. data/lib/dynamoid/middleware/identity_map.rb +1 -0
  47. data/lib/dynamoid/persistence.rb +452 -106
  48. data/lib/dynamoid/persistence/import.rb +1 -0
  49. data/lib/dynamoid/persistence/save.rb +1 -0
  50. data/lib/dynamoid/persistence/update_fields.rb +1 -0
  51. data/lib/dynamoid/persistence/upsert.rb +1 -0
  52. data/lib/dynamoid/primary_key_type_mapping.rb +1 -0
  53. data/lib/dynamoid/railtie.rb +1 -0
  54. data/lib/dynamoid/tasks/database.rb +1 -0
  55. data/lib/dynamoid/type_casting.rb +12 -0
  56. data/lib/dynamoid/undumping.rb +8 -0
  57. data/lib/dynamoid/validations.rb +2 -0
  58. data/lib/dynamoid/version.rb +1 -1
  59. metadata +7 -19
@@ -4,6 +4,7 @@ require 'securerandom'
4
4
 
5
5
  module Dynamoid
6
6
  module Persistence
7
+ # @private
7
8
  class Import
8
9
  def self.call(model_class, array_of_attributes)
9
10
  new(model_class, array_of_attributes).call
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Dynamoid
4
4
  module Persistence
5
+ # @private
5
6
  class Save
6
7
  def self.call(model)
7
8
  new(model).call
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Dynamoid
4
4
  module Persistence
5
+ # @private
5
6
  class UpdateFields
6
7
  def self.call(*args)
7
8
  new(*args).call
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Dynamoid
4
4
  module Persistence
5
+ # @private
5
6
  class Upsert
6
7
  def self.call(*args)
7
8
  new(*args).call
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dynamoid
4
+ # @private
4
5
  class PrimaryKeyTypeMapping
5
6
  def self.dynamodb_type(type, options)
6
7
  if type.is_a?(Class)
@@ -3,6 +3,7 @@
3
3
  if defined? Rails
4
4
 
5
5
  module Dynamoid
6
+ # @private
6
7
  class Railtie < Rails::Railtie
7
8
  rake_tasks do
8
9
  Dir[File.join(File.dirname(__FILE__), 'tasks/*.rake')].each { |f| load f }
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dynamoid
4
+ # @private
4
5
  module Tasks
5
6
  module Database
6
7
  module_function
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dynamoid
4
+ # @private
4
5
  module TypeCasting
5
6
  def self.cast_attributes(attributes, attributes_options)
6
7
  {}.tap do |h|
@@ -35,6 +36,7 @@ module Dynamoid
35
36
  when :raw then RawTypeCaster
36
37
  when :serialized then SerializedTypeCaster
37
38
  when :boolean then BooleanTypeCaster
39
+ when :binary then BinaryTypeCaster
38
40
  when Class then CustomTypeCaster
39
41
  end
40
42
 
@@ -283,6 +285,16 @@ module Dynamoid
283
285
  end
284
286
  end
285
287
 
288
+ class BinaryTypeCaster < Base
289
+ def process(value)
290
+ if value.is_a? String
291
+ value.dup
292
+ else
293
+ value.to_s
294
+ end
295
+ end
296
+ end
297
+
286
298
  class CustomTypeCaster < Base
287
299
  end
288
300
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dynamoid
4
+ # @private
4
5
  module Undumping
5
6
  def self.undump_attributes(attributes, attributes_options)
6
7
  {}.tap do |h|
@@ -38,6 +39,7 @@ module Dynamoid
38
39
  when :raw then RawUndumper
39
40
  when :serialized then SerializedUndumper
40
41
  when :boolean then BooleanUndumper
42
+ when :binary then BinaryUndumper
41
43
  when Class then CustomTypeUndumper
42
44
  end
43
45
 
@@ -262,6 +264,12 @@ module Dynamoid
262
264
  end
263
265
  end
264
266
 
267
+ class BinaryUndumper < Base
268
+ def process(value)
269
+ Base64.strict_decode64(value)
270
+ end
271
+ end
272
+
265
273
  class CustomTypeUndumper < Base
266
274
  def process(value)
267
275
  field_class = @options[:type]
@@ -10,6 +10,7 @@ module Dynamoid
10
10
 
11
11
  # Override save to provide validation support.
12
12
  #
13
+ # @private
13
14
  # @since 0.2.0
14
15
  def save(options = {})
15
16
  options.reverse_merge!(validate: true)
@@ -28,6 +29,7 @@ module Dynamoid
28
29
 
29
30
  # Raise an error unless this object is valid.
30
31
  #
32
+ # @private
31
33
  # @since 0.2.0
32
34
  def save!
33
35
  raise Dynamoid::Errors::DocumentNotValid, self unless valid?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dynamoid
4
- VERSION = '3.5.0'
4
+ VERSION = '3.6.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Symonds
@@ -21,7 +21,7 @@ authors:
21
21
  autorequire:
22
22
  bindir: bin
23
23
  cert_chain: []
24
- date: 2020-04-04 00:00:00.000000000 Z
24
+ date: 2020-07-13 00:00:00.000000000 Z
25
25
  dependencies:
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activemodel
@@ -65,20 +65,6 @@ dependencies:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '1.0'
68
- - !ruby/object:Gem::Dependency
69
- name: null-logger
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- type: :runtime
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0'
82
68
  - !ruby/object:Gem::Dependency
83
69
  name: appraisal
84
70
  requirement: !ruby/object:Gem::Requirement
@@ -262,6 +248,7 @@ files:
262
248
  - lib/dynamoid/identity_map.rb
263
249
  - lib/dynamoid/indexes.rb
264
250
  - lib/dynamoid/loadable.rb
251
+ - lib/dynamoid/log/formatter.rb
265
252
  - lib/dynamoid/middleware/identity_map.rb
266
253
  - lib/dynamoid/persistence.rb
267
254
  - lib/dynamoid/persistence/import.rb
@@ -282,8 +269,9 @@ licenses:
282
269
  - MIT
283
270
  metadata:
284
271
  bug_tracker_uri: https://github.com/Dynamoid/dynamoid/issues
285
- changelog_uri: https://github.com/Dynamoid/dynamoid/tag/v3.5.0/CHANGELOG.md
286
- source_code_uri: https://github.com/Dynamoid/dynamoid/tree/v3.5.0
272
+ changelog_uri: https://github.com/Dynamoid/dynamoid/tree/v3.6.0/CHANGELOG.md
273
+ source_code_uri: https://github.com/Dynamoid/dynamoid/tree/v3.6.0
274
+ documentation_uri: https://rubydoc.info/gems/dynamoid/3.6.0
287
275
  post_install_message:
288
276
  rdoc_options: []
289
277
  require_paths:
@@ -299,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
299
287
  - !ruby/object:Gem::Version
300
288
  version: '0'
301
289
  requirements: []
302
- rubygems_version: 3.0.3
290
+ rubygems_version: 3.1.2
303
291
  signing_key:
304
292
  specification_version: 4
305
293
  summary: Dynamoid is an ORM for Amazon's DynamoDB