refining 0.0.2 → 0.0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/refining.rb +5 -5
- metadata +3 -2
data/lib/refining.rb
CHANGED
@@ -10,14 +10,14 @@
|
|
10
10
|
# 0. You just DO WHAT THE FUCK YOU WANT TO.
|
11
11
|
#++
|
12
12
|
|
13
|
-
class
|
13
|
+
class Module
|
14
14
|
def refine_method (meth, &block)
|
15
15
|
return unless block
|
16
16
|
|
17
|
-
old =
|
17
|
+
old = instance_method(meth) rescue proc {}
|
18
18
|
|
19
19
|
define_method(meth) {|*args|
|
20
|
-
|
20
|
+
instance_exec((old.is_a?(UnboundMethod) ? old.bind(self) : old), *args, &block)
|
21
21
|
}
|
22
22
|
end
|
23
23
|
|
@@ -25,11 +25,11 @@ class Class
|
|
25
25
|
class << self
|
26
26
|
self
|
27
27
|
end.refine_method meth, &block
|
28
|
-
end
|
28
|
+
end; alias refine_module_method refine_class_method
|
29
29
|
end
|
30
30
|
|
31
31
|
class Object
|
32
|
-
def
|
32
|
+
def refine_instance_method (meth, &block)
|
33
33
|
class << self
|
34
34
|
self
|
35
35
|
end.refine_method meth, &block
|
metadata
CHANGED