rebinder 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ class Method
4
+ def rebind(*args,&block)
5
+ unbind.bind(*args,&block)
6
+ end
7
+ alias ✈ rebind
8
+ end
9
+
10
+ class UnboundMethod
11
+ def to_proc
12
+ proc { |obj| self.bind(obj).call }
13
+ end
14
+
15
+ def apply(obj)
16
+ bind(obj).call
17
+ end
18
+ alias ☏ apply
19
+ end
20
+
21
+ class Module
22
+
23
+ class BadIdeaProxy < BasicObject
24
+
25
+ def initialize(obj)
26
+ @obj = obj
27
+ end
28
+
29
+ def method_missing(s)
30
+ @obj.instance_method(s)
31
+ end
32
+
33
+ end
34
+
35
+ def snowman(arg=nil)
36
+ return instance_method(arg) if arg
37
+ BadIdeaProxy.new(self)
38
+ end
39
+
40
+ alias ☃ snowman
41
+
42
+ end
43
+
44
+ # id = Object.☃.object_id
45
+ # #=> #<UnboundMethod: Object(Kernel)#object_id>
46
+ #
47
+ # [:omg, :wtf, :lol].map(&id)
48
+ # #=> [507368, 507528, 507688]
49
+ #
50
+ # id.☏ :lmao
51
+ # #=> 507048
52
+ #
53
+ # add = 5.method(:+)
54
+ #
55
+ # [1,2,3].map(&add)
56
+ # #=> [6,7,8]
57
+ #
58
+ # [1,2,3].map(&add.✈ 10)
59
+ # #=> [11,12,13]
60
+
@@ -1,3 +1,3 @@
1
1
  module Rebinder
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rebinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -22,7 +22,7 @@ files:
22
22
  - .gitignore
23
23
  - Gemfile
24
24
  - Rakefile
25
- - lib/rebind.rb
25
+ - lib/rebinder.rb
26
26
  - lib/rebinder/version.rb
27
27
  - rebinder.gemspec
28
28
  homepage: ''
@@ -1,5 +0,0 @@
1
- class Method
2
- def rebind(*args,&block)
3
- unbind.bind(*args,&block)
4
- end
5
- end