method_found 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/method_found/interceptor.rb +13 -6
- data/lib/method_found/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9de7a0b0880e53f1c96603d88fa416c025a4e29d
|
4
|
+
data.tar.gz: 4b65ed2fbf1926df69dc140341c677240fcc3a4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ad77664bf164a317b348a0af8822ec3532b2b688909fb216635abf7dacba6b70a185ee8cf8b53025972969ff7e96e42f1babd4a999d143a22700d1ca62b3f32
|
7
|
+
data.tar.gz: d35e820982307478a88e09ccf0b7c2c35725123f429d9795466c3b7451a51e278e395c73f0b0710e2c8d38f81797da7653503da5d090efd9796f454bb4cc0c2e
|
data/README.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
module MethodFound
|
2
2
|
class Interceptor < Module
|
3
|
-
|
3
|
+
attr_reader :regex
|
4
|
+
|
5
|
+
def initialize(regex = nil, &intercept_block)
|
6
|
+
define_method_missing(regex, &intercept_block) unless regex.nil?
|
7
|
+
end
|
8
|
+
|
9
|
+
def define_method_missing(regex, &intercept_block)
|
10
|
+
@regex = regex
|
4
11
|
define_method :method_missing do |method_name, *arguments, &method_block|
|
5
12
|
if matches = regex.match(method_name)
|
6
13
|
instance_exec(method_name, matches, *arguments, &intercept_block)
|
@@ -12,12 +19,12 @@ module MethodFound
|
|
12
19
|
define_method :respond_to_missing? do |method_name, include_private = false|
|
13
20
|
(method_name =~ regex) || super(method_name, include_private)
|
14
21
|
end
|
22
|
+
end
|
15
23
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
24
|
+
def inspect
|
25
|
+
klass = self.class
|
26
|
+
name = klass.name || klass.inspect
|
27
|
+
"#<#{name}: #{regex.inspect}>"
|
21
28
|
end
|
22
29
|
end
|
23
30
|
end
|
data/lib/method_found/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: method_found
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Salzberg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|