around_the_world 0.23.3 → 0.23.4

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: fafff3aedd6efd98d5114af5c4910af0aca7252bea80091382dab3fe7c7bd5fb
4
- data.tar.gz: 6038aa1b445beebd7a066397838f7600999be195c34e8580869f5810eaeb6204
3
+ metadata.gz: 39523a91ec8f7bbd109e5d7f84d6c9065a005d4a68a9dfca287f5c5b3719fbc8
4
+ data.tar.gz: '0875953b877c715e7cc79b43e75e279b22d67eaed7e11d43089a15a44666e2d4'
5
5
  SHA512:
6
- metadata.gz: 586d9126b97c271775160d21d21bbb6384e63e33eca890bf8ccc83b2547edd25db4281832e2543bdb5610f6707e716d909d58826e84a60fcf2470b3da462f57d
7
- data.tar.gz: f4e9d6ff94769138dcf6b4b0c8424472bc094171c8d2a4d65b5cbc44ecfd5f7d6581751808ff9f491953643244bfc0430e5235595035df6795f23f4ce5398d24
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
- true
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
  ```
@@ -76,19 +76,21 @@ module AroundTheWorld
76
76
  # => "It works for class methods too!"
77
77
  #
78
78
  # @api public
79
- # @param method_name [Symbol]
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(method_name, prevent_double_wrapping_for: nil, allow_undefined_method: false, &block)
85
- MethodWrapper.wrap(
86
- method_name: method_name,
87
- target: self,
88
- prevent_double_wrapping_for: prevent_double_wrapping_for,
89
- allow_undefined_method: allow_undefined_method,
90
- &block
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module AroundTheWorld
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.23.3"
5
+ VERSION = "0.23.4"
6
6
  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.3
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.3
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.0.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