hook_method 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hook_method.rb +5 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12932a197c3a3c6e8a172a9db81e0800d2efcf46
|
4
|
+
data.tar.gz: 1c41de80bace55da1c00fae694165e6604bbe760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d68c916d04578146834173849e4fd32d824600c1955920076daf02b5153793e411283683e74115561eea339761fe2126f7a4e08f6363c5e4f8f7a3562550e248
|
7
|
+
data.tar.gz: 8b4f2bcc76ca277919b5c1933060a0d34da58937814858dfbcb633c19f8289824ff15151a5071e746f28b1aa265fecbf0325c61ebc86c4b777799977dec0f7ba
|
data/lib/hook_method.rb
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
|
4
4
|
class Class
|
5
5
|
@@hooked = []
|
6
|
+
|
6
7
|
def pre_execute_method(execute_method_name, hook_method_name)
|
7
|
-
return if @@hooked.any?{|hook| hook.strategy == :pre && hook.execute_method_name == execute_method_name && hook.hook_method_name == hook_method_name}
|
8
|
-
@@hooked << OpenStruct.new(strategy: :pre, execute_method_name: execute_method_name, hook_method_name: hook_method_name)
|
8
|
+
return if @@hooked.any? {|hook| hook.class_name == self && hook.strategy == :pre && hook.execute_method_name == execute_method_name && hook.hook_method_name == hook_method_name}
|
9
|
+
@@hooked << OpenStruct.new(class_name: self, strategy: :pre, execute_method_name: execute_method_name, hook_method_name: hook_method_name)
|
9
10
|
pre_method = instance_method(execute_method_name.id2name)
|
10
11
|
hook_method = instance_method(hook_method_name.id2name)
|
11
12
|
define_method(hook_method_name) do |*args|
|
@@ -15,8 +16,8 @@ class Class
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def post_execute_method(execute_method_name, hook_method_name)
|
18
|
-
return if @@hooked.any?{|hook| hook.strategy == :post && hook.execute_method_name == execute_method_name && hook.hook_method_name == hook_method_name}
|
19
|
-
@@hooked << OpenStruct.new(strategy: :post, execute_method_name: execute_method_name, hook_method_name: hook_method_name)
|
19
|
+
return if @@hooked.any? {|hook| hook.class_name == self && hook.strategy == :post && hook.execute_method_name == execute_method_name && hook.hook_method_name == hook_method_name}
|
20
|
+
@@hooked << OpenStruct.new(class_name: self, strategy: :post, execute_method_name: execute_method_name, hook_method_name: hook_method_name)
|
20
21
|
post_method = instance_method(execute_method_name.id2name)
|
21
22
|
hook_method = instance_method(hook_method_name.id2name)
|
22
23
|
define_method(hook_method_name) do |*args|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hook_method
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nyaahara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09
|
11
|
+
date: 2017-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Hook the method call
|
14
14
|
email:
|
@@ -40,8 +40,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
42
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.5.1
|
43
|
+
rubygems_version: 2.4.5.1
|
44
44
|
signing_key:
|
45
45
|
specification_version: 4
|
46
46
|
summary: Hook the method call
|
47
47
|
test_files: []
|
48
|
+
has_rdoc:
|