refining 0.0.1.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/refining.rb +10 -18
  2. metadata +14 -3
@@ -10,18 +10,6 @@
10
10
  # 0. You just DO WHAT THE FUCK YOU WANT TO.
11
11
  #++
12
12
 
13
- class Object
14
- def refine_method (meth, &block)
15
- return unless block
16
-
17
- old = self.method(meth) rescue Proc.new {}
18
-
19
- define_singleton_method(meth) {|*args|
20
- self.instance_exec(old, *args, &block)
21
- }
22
- end
23
- end
24
-
25
13
  class Class
26
14
  def refine_method (meth, &block)
27
15
  return unless block
@@ -34,12 +22,16 @@ class Class
34
22
  end
35
23
 
36
24
  def refine_class_method (meth, &block)
37
- return unless block
38
-
39
- old = self.method(meth) rescue Proc.new {}
25
+ class << self
26
+ self
27
+ end.refine_method meth, &block
28
+ end
29
+ end
40
30
 
41
- define_singleton_method(meth) {|*args|
42
- self.instance_exec((old.is_a?(Proc) ? old : old.bind(self)), *args, &block)
43
- }
31
+ class Object
32
+ def refine_method (meth, &block)
33
+ class << self
34
+ self
35
+ end.refine_method meth, &block
44
36
  end
45
37
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refining
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease:
5
- version: 0.0.1.1
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
6
11
  platform: ruby
7
12
  authors:
8
13
  - meh.
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-07-19 00:00:00 Z
18
+ date: 2011-08-13 00:00:00 Z
14
19
  dependencies: []
15
20
 
16
21
  description:
@@ -36,17 +41,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
36
41
  requirements:
37
42
  - - ">="
38
43
  - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
39
47
  version: "0"
40
48
  required_rubygems_version: !ruby/object:Gem::Requirement
41
49
  none: false
42
50
  requirements:
43
51
  - - ">="
44
52
  - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
45
56
  version: "0"
46
57
  requirements: []
47
58
 
48
59
  rubyforge_project:
49
- rubygems_version: 1.8.5
60
+ rubygems_version: 1.8.6
50
61
  signing_key:
51
62
  specification_version: 3
52
63
  summary: Easily refine methods