simple_aspect 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: e991b108ddd328284fb3ce188939bf5a725482b1
4
- data.tar.gz: 81e062bfdfc0e338fb13281be91eed674e42f4a0
3
+ metadata.gz: d4d10294dae057f9b624813a323f1195f33792c7
4
+ data.tar.gz: 47f0750698a998be89ff0fb06854440fad86ad04
5
5
  SHA512:
6
- metadata.gz: 11f0ed8fb7a82d60d7c4768ab67bbf9e96f44573f144d9a80973aeeb8a7901f5b6dd5c19f4ed0d740f6de43e05f0e8a7c0755983c4196384c34938d6f73c5c44
7
- data.tar.gz: ba9b6f33b50018731847f2100165e1d4678ea015552777aefdf8d6965935ab5fec73f25e503e35300ef90a7f73ab53eaa6910cd5706b71ce1e2a18974d3ab0ca
6
+ metadata.gz: ab95a34f6118aa21a8b8cbc260c250331708b47bc63f8d08e5a368515e6a5f55313e25cf688387396968104bfe6b1956ffa5efecd62f3ab15dabb18842a6ed74
7
+ data.tar.gz: 08daefe1dc62a9d1d0f9a84a79a8c08e994392c22e1a59395f21a559ba0cdc3e5a9bf68e6792829485e4ae56d85831907ca920fbe419f4ef56eaf1d210fed9e7
data/lib/simple_aspect.rb CHANGED
@@ -3,6 +3,7 @@ require 'simple_aspect/version'
3
3
  module SimpleAspect
4
4
  require 'thread'
5
5
 
6
+ # @api private
6
7
  def self.extended(base)
7
8
  base.instance_eval do
8
9
  @sa_methods_to_aspect_methods_name = {}
@@ -11,6 +12,51 @@ module SimpleAspect
11
12
  end
12
13
  end
13
14
 
15
+ # Register an aspect method around the target method
16
+ #
17
+ # @param method [Symbol] name of the target method
18
+ # @param instance_around_method_name [Symbol] name of the aspect method. If
19
+ # not provided, the definition of the aspect method should be provided with
20
+ # a Proc/lambda
21
+ # @param block [Proc] the definition of the aspect method if its name was not
22
+ # provided. This Proc needs to receive two arguments: *orig_args,
23
+ # &orig_block
24
+ #
25
+ # @example without a defined method
26
+ # class Worker
27
+ # extend SimpleAspect
28
+ #
29
+ # aspect_around :perform do |*args, &original|
30
+ # result = original.call
31
+ # log(result)
32
+ # end
33
+ #
34
+ # def perform(*args)
35
+ # # do_work
36
+ # end
37
+ #
38
+ # def log(message)
39
+ # # log
40
+ # end
41
+ # end
42
+ #
43
+ # @example with a defined method
44
+ #
45
+ # class Worker
46
+ # extend SimpleAspect
47
+ #
48
+ # aspect_around :perform, :log
49
+ #
50
+ # def perform(*args)
51
+ # # do_work
52
+ # end
53
+ #
54
+ # def log(*args)
55
+ # # log *args
56
+ # result = yield
57
+ # # log result
58
+ # end
59
+ # end
14
60
  def aspect_around(
15
61
  method,
16
62
  instance_around_method_name = sa_instance_around_method_name(method),
@@ -19,6 +65,7 @@ module SimpleAspect
19
65
  sa_register_aspect_on_method(method, instance_around_method_name, &block)
20
66
  end
21
67
 
68
+ # @api private
22
69
  def method_added(method)
23
70
  return if sa_should_not_redefine?(method)
24
71
 
@@ -1,3 +1,3 @@
1
1
  module SimpleAspect
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_aspect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Tealdi