dynamodb_record 0.3.2 → 0.3.4
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b67b72cf325a7a48938779d0653b0b963d5f07b53cb8b7557e8553938cc2a71c
|
4
|
+
data.tar.gz: 2d6f94604e4c5b6648cbcdff39cbcd3ea40530897751aabcb1de4cbd8515029a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e49a7c643ac033095d46a5cded42f761f4240f3b1538ab041c2e10b0439607eed088434f0cb0a8f11f4bc530a3bb7f9d63401d4c0735e9384d100271f4324be
|
7
|
+
data.tar.gz: d4edeceef449427a3592d348062cb6c07709a8741f9879be08ce094601fdbca6e7e7fa8ab939691db11bb54fb1427801a0e50cfe54627e74f081c16e6706f8fa
|
@@ -17,7 +17,7 @@ module DynamodbRecord
|
|
17
17
|
|
18
18
|
# rubocop:disable Naming/PredicateName
|
19
19
|
def has_many(associations)
|
20
|
-
base_model = to_s.downcase
|
20
|
+
base_model = to_s.downcase.split('::').last
|
21
21
|
model = associations.to_s.chop
|
22
22
|
|
23
23
|
define_method(associations) do
|
@@ -36,7 +36,7 @@ module DynamodbRecord
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def has_many_through(associations, table)
|
39
|
-
base_model = to_s.downcase
|
39
|
+
base_model = to_s.downcase.split('::').last
|
40
40
|
relation_model = associations.to_s.chop
|
41
41
|
list = []
|
42
42
|
list << base_model
|
@@ -69,7 +69,7 @@ module DynamodbRecord
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def has_and_belongs_to_many(associations)
|
72
|
-
base_model = to_s.downcase
|
72
|
+
base_model = to_s.downcase.split('::').last
|
73
73
|
relation_model = associations.to_s.chop
|
74
74
|
list = []
|
75
75
|
list << base_model
|
@@ -11,11 +11,11 @@ module DynamodbRecord
|
|
11
11
|
@klass = @pager.klass
|
12
12
|
@options = @pager.options
|
13
13
|
@items = []
|
14
|
+
@base_model = @klass.to_s.downcase.split('::').last
|
14
15
|
@pager.items.each do |item|
|
15
|
-
# p item
|
16
16
|
object = @klass.client.get_item(
|
17
17
|
table_name: @klass.table_name,
|
18
|
-
key: {id: item["#{@
|
18
|
+
key: {id: item["#{@base_model}_id"]}
|
19
19
|
)
|
20
20
|
@items << @klass.send(:from_database, object.item)
|
21
21
|
end
|
@@ -44,7 +44,7 @@ module DynamodbRecord
|
|
44
44
|
def <<(object)
|
45
45
|
table_name = @options[:table_name]
|
46
46
|
item = @options[:expression_attribute_values].transform_keys { |k| k.delete_prefix(':').to_sym }
|
47
|
-
item[:"#{@
|
47
|
+
item[:"#{@base_model}_id"] = object.id
|
48
48
|
key = {table_name:, item:}
|
49
49
|
@klass.client.put_item(key)
|
50
50
|
@items << object
|
data/lib/dynamodb_record.rb
CHANGED