hanami-mongoid 0.1.2 → 0.1.3

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: 216f0e6cb5b8ad59810e6bd780868fee7ec1485971f74ab82b0ce8494d8f6c22
4
- data.tar.gz: ec3e19bc2e94efd130b2c0caa57dc383b7f5d3c3f80845583ea129ed976fabcd
3
+ metadata.gz: 8aa04811270cc7992c7da3260c0b574090cd44e1b119b936c039290264fcd245
4
+ data.tar.gz: 8588ab96c57fd373424b8565c6febc905ca5eff76fb882d91d97fc72539fb817
5
5
  SHA512:
6
- metadata.gz: 1151e04a0270be5687a12bc317853a18c688cba775619737722a8b6774c3e11b70b7a39384e256d33ce0d7050033c59502984a038e2a0d323726bd33530a70ad
7
- data.tar.gz: 5d719ca1ed32a84cad3bcc148453df6db50b5f603d2c92db3291a74a7c60bfa8d4b62876f8855dec418b407bd78838f79fff7e72cab69d9587e7a58f073568ab
6
+ metadata.gz: 68abc67ec639d3cf1e288d0d408be1c35ac02ec4905b922c423dfcc2588a305fcf517d710280eedfda3cc4879a6839545907106c2242cbd2c865f99d5a6f4b05
7
+ data.tar.gz: d5e8c9de62519c80985ba46de6bf629316022a2e626b8a3d46dd4075046f9b6d6b314872be847032ab38955490de59908022b1d98cd57d34811ce3be6626f7c6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hanami-mongoid (0.1.0)
4
+ hanami-mongoid (0.1.3)
5
5
  mongoid
6
6
 
7
7
  GEM
@@ -12,13 +12,23 @@ module Hanami
12
12
 
13
13
  ##
14
14
  # Forwards common repository methods to the model
15
- %i( find find_by where any_of all first last new create
15
+ %i( find find_by where any_of all first last
16
16
  destroy_all delete_all update_all ).each do |method|
17
17
  define_method method do |*args|
18
18
  self.model_klass.send method, *args
19
19
  end
20
20
  end
21
21
 
22
+ ##
23
+ # Forwards create method to accept a model instance
24
+ define_method :create do |model_instance|
25
+ if model_instance.is_a? self.model_klass
26
+ model_instance.save
27
+ else
28
+ self.model_klass.create(model_instance)
29
+ end
30
+ end
31
+
22
32
  ##
23
33
  # Forwards common repository methods to the model instance
24
34
  %i( destroy delete update_attributes update ).each do |method|
@@ -1,5 +1,5 @@
1
1
  module Hanami
2
2
  module Mongoid
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Ballardin