clean-annotations 0.2.0 → 0.4.0
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/.version +1 -1
- data/lib/clean-annotations.rb +4 -0
- data/lib/clean-annotations/method_attr.rb +2 -2
- data/lib/clean-annotations/rescue_from.rb +38 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f4b1010c1932dceaa3b47119e7355bd9429f191d64253b93b84a9738b8c42f5
|
4
|
+
data.tar.gz: ff7586b5e7648680184aa2dac1f1b5161ac149baba75a7c39c8e210de18d8682
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32cf18f49d2b60db203fc9327cabeedc63ba18d1b1b9b3ec64f4e41b4e64a45bee67810bf28f67cb22e706b5c8a5ee7d574f74059684963dc5d946e90b9e8352
|
7
|
+
data.tar.gz: ccd044c4c5798c35e6bc1501bb4bf938a2f8dd4bca4797b63b8aaa1f4dfc865de3600012f311ea9b3ca20431b0939035dda6921e35085839bc22ffc4f9fb0c41
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/clean-annotations.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
module RescueFromError
|
2
|
+
extend self
|
3
|
+
|
4
|
+
RESCUES ||= {}
|
5
|
+
|
6
|
+
def included base
|
7
|
+
def base.rescue_from what, &block
|
8
|
+
raise ArgumemtError.new('Unsupported') if what.is_a?(Symbol) && what != :all
|
9
|
+
|
10
|
+
key = [self, what].join('-')
|
11
|
+
RESCUES[key] = block
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def resolve_rescue_from
|
16
|
+
begin
|
17
|
+
yield
|
18
|
+
rescue => error
|
19
|
+
for klass in self.class.ancestors
|
20
|
+
key = [klass, error.class].join('-')
|
21
|
+
|
22
|
+
if block = RESCUES[key]
|
23
|
+
return instance_exec(error, &block)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
for klass in self.class.ancestors
|
28
|
+
key = [klass, :all].join('-')
|
29
|
+
|
30
|
+
if block = RESCUES[key]
|
31
|
+
return instance_exec(error, &block)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clean-annotations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dino Reic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Define annotatable attribute names and assign them to methods or classes,
|
14
14
|
add callbacks to non-Rails classes. Void of dependencies.
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- "./lib/clean-annotations/class_attribute.rb"
|
23
23
|
- "./lib/clean-annotations/class_callbacks.rb"
|
24
24
|
- "./lib/clean-annotations/method_attr.rb"
|
25
|
+
- "./lib/clean-annotations/rescue_from.rb"
|
25
26
|
homepage: https://github.com/dux/clean-annotations
|
26
27
|
licenses:
|
27
28
|
- MIT
|