hanami-mongoid 0.1.6 → 0.1.7
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 +4 -4
- data/lib/hanami/mongoid/repository.rb +21 -9
- data/lib/hanami/mongoid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7050c95dddb74e5f8a9704f622f27aa0b827aacaecb5385f8cef19ae27806a2
|
4
|
+
data.tar.gz: '097622667f1803c926d03f8f938b087d1a74482009b54f006104db5f8bd53747'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f93f89a899fb259451ddd4c849b146eb211856a28f8782c394f5e8f0fc8e95fe8de7a94ffbd173824692ac0f8cc3b1f55f72ca8380d63a8bc895e7ad25513b3
|
7
|
+
data.tar.gz: 2c0933ad41794d210f5b8a247df279be92a638729333924c2bce9dd42eb0d1af9c5ff921082f71762f8c81c2b69aaf3a40fcc423b1f31c7463648ec9c41aad47
|
@@ -21,20 +21,32 @@ module Hanami
|
|
21
21
|
|
22
22
|
##
|
23
23
|
# Forwards create method to accept a model instance
|
24
|
-
define_method :create do |
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
define_method :create do |entity_instance|
|
25
|
+
unless entity_instance.is_a? self.model_klass
|
26
|
+
entity_instance = self.model_klass.new(entity_instance)
|
27
|
+
end
|
28
|
+
entity_instance.save(validate: false)
|
29
|
+
entity_instance
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Forwards update methods to accept a model instance
|
34
|
+
%i( update_attributes update ).each do |method|
|
35
|
+
define_method :update do |entity_id, entity_attributes|
|
36
|
+
entity_instance = self.model_klass.find(entity_id)
|
37
|
+
if entity_instance.present?
|
38
|
+
entity_instance.assign_attributes(entity_attributes)
|
39
|
+
entity_instance.save(validate: false)
|
40
|
+
entity_instance
|
41
|
+
end
|
30
42
|
end
|
31
43
|
end
|
32
44
|
|
33
45
|
##
|
34
46
|
# Forwards common repository methods to the model instance
|
35
|
-
%i( destroy delete
|
36
|
-
define_method method do |entity_id
|
37
|
-
self.model_klass.find(entity_id)&.send method
|
47
|
+
%i( destroy delete ).each do |method|
|
48
|
+
define_method method do |entity_id|
|
49
|
+
self.model_klass.find(entity_id)&.send method
|
38
50
|
end
|
39
51
|
end
|
40
52
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Ballardin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|