asset_cloud 2.2.5 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/asset_cloud.gemspec +1 -1
- data/lib/asset_cloud/callbacks.rb +17 -4
- data/lib/asset_cloud/validations.rb +5 -2
- 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: b8da870cd7f0377f18b1ae46d7a4e8e69c2e4549f224e28df123f565d9e454d3
|
4
|
+
data.tar.gz: 190fea72f1ef76ffa7aad5931324be4cfc172903f41826a1485c2e859fae50dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb1dff12c4fb90328182f23c96daf17f3f9fddbc13c42dd569b0855545c4be0621aa8bd218c43fc57eb44716f27026e1ca703fea67cd214231ee654853decca6
|
7
|
+
data.tar.gz: e29ebc045b6eeac9705f5f758aca3fce768c6e9f8085ecc0502cbdecf1037621b504ab0c3c175f61e8faa912d16d5abef16f79c90941c02bbce865e8cc50cae1
|
data/asset_cloud.gemspec
CHANGED
@@ -3,6 +3,17 @@ module AssetCloud
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
module ClassMethods
|
6
|
+
attr_writer :_callbacks
|
7
|
+
|
8
|
+
def inherited(child)
|
9
|
+
super if defined? super
|
10
|
+
child._callbacks = _callbacks.deep_dup.freeze
|
11
|
+
end
|
12
|
+
|
13
|
+
def _callbacks
|
14
|
+
@_callbacks ||= {}.freeze
|
15
|
+
end
|
16
|
+
|
6
17
|
def callback_methods(*symbols)
|
7
18
|
symbols.each do |method|
|
8
19
|
define_callbacks(method)
|
@@ -23,12 +34,14 @@ module AssetCloud
|
|
23
34
|
|
24
35
|
define_singleton_method(before) do |*callbacks, &block|
|
25
36
|
callbacks << block if block_given?
|
26
|
-
|
37
|
+
callbacks = (_callbacks[before] || []) + callbacks
|
38
|
+
self._callbacks = _callbacks.merge(before => callbacks).freeze
|
27
39
|
end
|
28
40
|
|
29
41
|
define_singleton_method(after) do |*callbacks, &block|
|
30
42
|
callbacks << block if block_given?
|
31
|
-
|
43
|
+
callbacks = (_callbacks[after] || []) + callbacks
|
44
|
+
self._callbacks = _callbacks.merge(after => callbacks).freeze
|
32
45
|
end
|
33
46
|
end
|
34
47
|
|
@@ -49,7 +62,7 @@ module AssetCloud
|
|
49
62
|
|
50
63
|
result = case callback
|
51
64
|
when Symbol
|
52
|
-
|
65
|
+
send(callback, *args)
|
53
66
|
when Proc, Method
|
54
67
|
callback.call(self, *args)
|
55
68
|
else
|
@@ -65,7 +78,7 @@ module AssetCloud
|
|
65
78
|
end
|
66
79
|
|
67
80
|
def callbacks_for(symbol)
|
68
|
-
self.class.
|
81
|
+
self.class._callbacks[symbol] || []
|
69
82
|
end
|
70
83
|
end
|
71
84
|
end
|
@@ -14,9 +14,12 @@ module AssetCloud
|
|
14
14
|
end
|
15
15
|
|
16
16
|
module ClassMethods
|
17
|
-
def validate(*
|
17
|
+
def validate(*extra_validations, &block)
|
18
|
+
validations = self._callbacks[:validate] || []
|
19
|
+
validations += extra_validations
|
18
20
|
validations << block if block_given?
|
19
|
-
|
21
|
+
|
22
|
+
self._callbacks = _callbacks.merge(validate: validations.freeze).freeze
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asset_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|