method_decorator 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a702124860b5185e5110d615d2907ebe60186dcb
4
- data.tar.gz: 7233f91bbdb27264c7fbce0581277564f298e399
3
+ metadata.gz: be0a9514d16986f1226824039aae623898876f14
4
+ data.tar.gz: bfa76543251a5212967d7b524a4800b468857239
5
5
  SHA512:
6
- metadata.gz: 440e73547765205775340efa47577d570af2878d9ac2975c67e03a56cdeb91dacba4b92a67f127590aac02105a2d3007540be3351dd5ffd72564300ccf0b8cf2
7
- data.tar.gz: fc2fe1761d13dd1a5e92ffba41f8da7fb04ce0e9e1d306fbf4ccd772033a40c8831bee09851caaf64c30d6e728e2f65f473b07f9f999ccc7a0ec534e4504fe8d
6
+ metadata.gz: a0d4e40c492f07d3ded55ba928723c5568b17e6cc8498bcb962e7e69a96d135a95f8876e33a11f1ad461bc5ccfa1a145d3d897664cb2a847de4ce6baa817e64e
7
+ data.tar.gz: ff8757256465330b96ae9c29bb7b079f3c86c02c5f1162cccee13f08d5d94a89c3bdd976b1dd11b77b892d0e4268b12164a56c0c49dd69b874a3944af1b35b24
data/README.rdoc CHANGED
@@ -15,10 +15,9 @@ For a given class (with unnecessary complex logic, just to make a point):
15
15
  include MethodDecorator
16
16
 
17
17
  method_to_override = :some_method
18
- original_method_name = original_method_name_for(method_to_override)
19
- decorate_method method_to_override do |some_arg|
18
+ decorate_method method_to_override do |*args|
20
19
  puts :decorated_some_method
21
- send original_method_name, some_arg
20
+ call_original_method method_to_override, *args
22
21
  end
23
22
 
24
23
  end
@@ -30,12 +29,4 @@ This call:
30
29
  Produces this output:
31
30
 
32
31
  decorated_some_method
33
- some arg
34
-
35
- == Next moves
36
-
37
- - Find a better way to call the original method, for now it's too verbose
38
-
39
- original_method_name = original_method_name_for(:some_method)
40
- ...
41
- send original_method_name, some_arg
32
+ some arg
@@ -1,3 +1,3 @@
1
1
  module MethodDecorator
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -23,6 +23,11 @@ module MethodDecorator extend ActiveSupport::Concern
23
23
 
24
24
  end
25
25
 
26
+ def call_original_method(target, *args, &block)
27
+ original_method_name = self.singleton_class.original_method_name_for target
28
+ send original_method_name, *args, &block
29
+ end
30
+
26
31
  end
27
32
 
28
33
  end
@@ -7,10 +7,9 @@ class SomeClass
7
7
  include MethodDecorator
8
8
 
9
9
  method_to_override = :some_method
10
- original_method_name = original_method_name_for(method_to_override)
11
- decorate_method method_to_override do |some_arg|
10
+ decorate_method method_to_override do |*args|
12
11
  puts :decorated_some_method
13
- send original_method_name, some_arg
12
+ call_original_method method_to_override, *args
14
13
  end
15
14
 
16
15
  class << self
@@ -22,10 +21,9 @@ class SomeClass
22
21
  include MethodDecorator
23
22
 
24
23
  method_to_override = :some_method
25
- original_method_name = original_method_name_for(method_to_override)
26
- decorate_method method_to_override do |some_arg|
24
+ decorate_method method_to_override do |*args|
27
25
  puts :decorated_some_method
28
- send original_method_name, some_arg
26
+ call_original_method method_to_override, *args
29
27
  end
30
28
 
31
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: method_decorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - r4z3c
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-02 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler