shrine-mongoid 1.0.0.beta → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shrine/plugins/mongoid.rb +32 -13
- data/shrine-mongoid.gemspec +3 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 652dcb0a00f126f58433cef6a38b376bfac679586cfd77b1cbb16317590d2429
|
4
|
+
data.tar.gz: 68deba00590e76f7ea98ea29a006e34f4e902d2716da5acbed574d1022af063f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6040eac599f17b0069dbf5a38a0a02ca98cff2e8271d30b4ef731487d646a26a7d2c357d43321d82194759065c0121e30f29139ad4b87afed0d760abf821d359
|
7
|
+
data.tar.gz: 8f32aeb9b0dcbb8292e9d8a365584c4f70e369500b6875670a1f958a9ef10cf5a1c5dfcd6b82b7e33c66a0c0c5964c005c26f45efc3b571ac4f438d1c9afc474
|
@@ -26,30 +26,21 @@ class Shrine
|
|
26
26
|
if shrine_class.opts[:mongoid][:validations]
|
27
27
|
# add validation plugin integration
|
28
28
|
model.validate do
|
29
|
-
|
30
|
-
|
31
|
-
send(:"#{name}_attacher").errors.each do |message|
|
32
|
-
errors.add(name, message)
|
33
|
-
end
|
29
|
+
send(:"#{name}_attacher").send(:mongoid_validate)
|
34
30
|
end
|
35
31
|
end
|
36
32
|
|
37
33
|
if shrine_class.opts[:mongoid][:callbacks]
|
38
34
|
model.before_save do
|
39
|
-
|
40
|
-
send(:"#{name}_attacher").save
|
41
|
-
end
|
35
|
+
send(:"#{name}_attacher").send(:mongoid_before_save)
|
42
36
|
end
|
43
37
|
|
44
38
|
model.after_save do
|
45
|
-
|
46
|
-
send(:"#{name}_attacher").finalize
|
47
|
-
send(:"#{name}_attacher").persist
|
48
|
-
end
|
39
|
+
send(:"#{name}_attacher").send(:mongoid_after_save)
|
49
40
|
end
|
50
41
|
|
51
42
|
model.after_destroy do
|
52
|
-
send(:"#{name}_attacher").
|
43
|
+
send(:"#{name}_attacher").send(:mongoid_after_destroy)
|
53
44
|
end
|
54
45
|
end
|
55
46
|
|
@@ -70,6 +61,34 @@ class Shrine
|
|
70
61
|
module AttacherMethods
|
71
62
|
private
|
72
63
|
|
64
|
+
def mongoid_validate
|
65
|
+
return unless respond_to?(:errors)
|
66
|
+
|
67
|
+
errors.each do |message|
|
68
|
+
record.errors.add(name, message)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Calls Attacher#save. Called before model save.
|
73
|
+
def mongoid_before_save
|
74
|
+
return unless changed?
|
75
|
+
|
76
|
+
save
|
77
|
+
end
|
78
|
+
|
79
|
+
# Finalizes attachment and persists changes. Called after model save.
|
80
|
+
def mongoid_after_save
|
81
|
+
return unless changed?
|
82
|
+
|
83
|
+
finalize
|
84
|
+
persist
|
85
|
+
end
|
86
|
+
|
87
|
+
# Deletes attached files. Called after model destroy.
|
88
|
+
def mongoid_after_destroy
|
89
|
+
destroy_attached
|
90
|
+
end
|
91
|
+
|
73
92
|
# Saves changes to the model instance, raising exception on validation
|
74
93
|
# errors. Used by the _persistence plugin.
|
75
94
|
def mongoid_persist
|
data/shrine-mongoid.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
|
-
gem.name
|
3
|
-
gem.version
|
2
|
+
gem.name = "shrine-mongoid"
|
3
|
+
gem.version = "1.0.0"
|
4
4
|
|
5
5
|
gem.required_ruby_version = ">= 2.3"
|
6
6
|
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "*.gemspec"]
|
14
14
|
gem.require_path = "lib"
|
15
15
|
|
16
|
-
gem.add_dependency "shrine", ">= 3.0.0.
|
16
|
+
gem.add_dependency "shrine", ">= 3.0.0.beta3", "< 4"
|
17
17
|
gem.add_dependency "mongoid", ">= 5.0"
|
18
18
|
|
19
19
|
gem.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shrine
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.0.0.
|
19
|
+
version: 3.0.0.beta3
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '4'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 3.0.0.
|
29
|
+
version: 3.0.0.beta3
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '4'
|
@@ -112,9 +112,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '2.3'
|
113
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubygems_version: 3.0.3
|
120
120
|
signing_key:
|