around_the_world 0.23.3 → 0.23.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/lib/around_the_world.rb +11 -9
- data/lib/around_the_world/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39523a91ec8f7bbd109e5d7f84d6c9065a005d4a68a9dfca287f5c5b3719fbc8
|
4
|
+
data.tar.gz: '0875953b877c715e7cc79b43e75e279b22d67eaed7e11d43089a15a44666e2d4'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db00f0de2c9967e679f7926525bcaca3139ea29baf66744dd5d81e67150d2ac760ababa527d3e1b0119276d3baf56924a15f40c0e12c8553d28890602ee95637
|
7
|
+
data.tar.gz: b844677b2d7828aaba2591e2d2896b9fe9ea9fb80015ab4c92af69fc490d73c1671c37527e40f70256d77ba3d2ace6a0c272f16dcefc079210af3997cec49750
|
data/README.md
CHANGED
@@ -40,11 +40,15 @@ Define a method that gets called _around_ the given instance method:
|
|
40
40
|
class SomeClass
|
41
41
|
include AroundTheWorld
|
42
42
|
|
43
|
+
def make_something_happen!
|
44
|
+
@something_happened = true
|
45
|
+
end
|
46
|
+
|
43
47
|
def did_something_happened?
|
44
|
-
|
48
|
+
!!@something_happened
|
45
49
|
end
|
46
|
-
|
47
|
-
around_method :did_something_happened? do |*args, **opts|
|
50
|
+
|
51
|
+
around_method :make_something_happen!, :did_something_happened? do |*args, **opts|
|
48
52
|
things_happened = super(*args, **opts)
|
49
53
|
|
50
54
|
if things_happened
|
@@ -57,6 +61,12 @@ end
|
|
57
61
|
```
|
58
62
|
|
59
63
|
```
|
64
|
+
> SomeClass.new.did_something_happened?
|
65
|
+
=> "Nothing to see here..."
|
66
|
+
|
67
|
+
> SomeClass.new.make_something_happen!
|
68
|
+
=> "Something happened!"
|
69
|
+
|
60
70
|
> SomeClass.new.did_something_happened?
|
61
71
|
=> "Something happened!"
|
62
72
|
```
|
data/lib/around_the_world.rb
CHANGED
@@ -76,19 +76,21 @@ module AroundTheWorld
|
|
76
76
|
# => "It works for class methods too!"
|
77
77
|
#
|
78
78
|
# @api public
|
79
|
-
# @param
|
79
|
+
# @param method_names [Array<Symbol, String>] A list of methods to be wrapped
|
80
80
|
# @param :prevent_double_wrapping_for [Object]
|
81
81
|
# If defined, this prevents wrapping the method twice for a given purpose. Accepts any argument.
|
82
82
|
# @param :allow_undefined_method [Boolean] When false, an error is raised if the wrapped method is not
|
83
83
|
# explicitly defined by the target module or class. Default: false
|
84
|
-
def around_method(
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
def around_method(*method_names, prevent_double_wrapping_for: nil, allow_undefined_method: false, &block)
|
85
|
+
method_names.each do |method_name|
|
86
|
+
MethodWrapper.wrap(
|
87
|
+
method_name: method_name,
|
88
|
+
target: self,
|
89
|
+
prevent_double_wrapping_for: prevent_double_wrapping_for,
|
90
|
+
allow_undefined_method: allow_undefined_method,
|
91
|
+
&block
|
92
|
+
)
|
93
|
+
end
|
92
94
|
end
|
93
95
|
end
|
94
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: around_the_world
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allen Rettberg
|
@@ -47,7 +47,7 @@ metadata:
|
|
47
47
|
homepage_uri: https://github.com/Freshly/spicerack/tree/master/around_the_world
|
48
48
|
source_code_uri: https://github.com/Freshly/spicerack/tree/master/around_the_world
|
49
49
|
changelog_uri: https://github.com/Freshly/spicerack/blob/master/around_the_world/CHANGELOG.md
|
50
|
-
documentation_uri: https://www.rubydoc.info/gems/around_the_world/0.23.
|
50
|
+
documentation_uri: https://www.rubydoc.info/gems/around_the_world/0.23.4
|
51
51
|
post_install_message:
|
52
52
|
rdoc_options: []
|
53
53
|
require_paths:
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
|
-
rubygems_version: 3.
|
66
|
+
rubygems_version: 3.1.2
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Allows you to easily wrap methods with custom logic on any class
|