binder 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/binder/object.rb CHANGED
@@ -9,9 +9,9 @@ class Object
9
9
  end
10
10
  end
11
11
 
12
- alias ask tell
13
- alias teach tell
14
- alias beg tell
12
+ alias_method :ask, :tell
13
+ alias_method :teach, :tell
14
+ alias_method :beg, :tell
15
15
 
16
16
  class << self
17
17
  def bind_in_context(method_name, closure, eval_context=:class_eval)
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Object do
4
- describe "#tell" do
4
+ describe "#tell/#ask/#teach/#beg" do
5
5
  it "should run the given block or proc inside the requested object closure" do
6
6
  class Baby
7
7
  def say_dada
8
8
  "waaaa"
9
9
  end
10
10
  end
11
-
11
+
12
12
  Object.new.tell(Baby.new) { say_dada }.should == "waaaa"
13
13
  Object.tell(Baby.new) { say_dada }.should == "waaaa"
14
14
  tell(Baby.new) { say_dada }.should == "waaaa"
@@ -24,6 +24,77 @@ describe Object do
24
24
  end
25
25
  end
26
26
 
27
+ describe "#ask" do
28
+ it "should run the given block or proc inside the requested object closure" do
29
+ class Baby
30
+ def say_dada
31
+ "waaaa"
32
+ end
33
+ end
34
+
35
+ Object.new.ask(Baby.new) { say_dada }.should == "waaaa"
36
+ Object.ask(Baby.new) { say_dada }.should == "waaaa"
37
+ ask(Baby.new) { say_dada }.should == "waaaa"
38
+
39
+ ask Baby.new, :to do
40
+ say_dada
41
+ end
42
+
43
+ to_say_dada = proc { say_dada }
44
+ Object.new.ask(Baby.new, to_say_dada).should == "waaaa"
45
+ Object.ask(Baby.new, to_say_dada).should == "waaaa"
46
+ ask(Baby.new, to_say_dada).should == "waaaa"
47
+ end
48
+ end
49
+
50
+ describe "#teach" do
51
+ it "should run the given block or proc inside the requested object closure" do
52
+ class Baby
53
+ def say_dada
54
+ "waaaa"
55
+ end
56
+ end
57
+
58
+ Object.new.teach(Baby.new) { say_dada }.should == "waaaa"
59
+ Object.teach(Baby.new) { say_dada }.should == "waaaa"
60
+ teach(Baby.new) { say_dada }.should == "waaaa"
61
+
62
+ teach Baby.new, :to do
63
+ say_dada
64
+ end
65
+
66
+ to_say_dada = proc { say_dada }
67
+ Object.new.teach(Baby.new, to_say_dada).should == "waaaa"
68
+ Object.teach(Baby.new, to_say_dada).should == "waaaa"
69
+ teach(Baby.new, to_say_dada).should == "waaaa"
70
+ end
71
+ end
72
+
73
+
74
+ describe "#beg" do
75
+ it "should run the given block or proc inside the requested object closure" do
76
+ class Baby
77
+ def say_dada
78
+ "waaaa"
79
+ end
80
+ end
81
+
82
+ Object.new.beg(Baby.new) { say_dada }.should == "waaaa"
83
+ Object.beg(Baby.new) { say_dada }.should == "waaaa"
84
+ beg(Baby.new) { say_dada }.should == "waaaa"
85
+
86
+ beg Baby.new, :to do
87
+ say_dada
88
+ end
89
+
90
+ to_say_dada = proc { say_dada }
91
+ Object.new.beg(Baby.new, to_say_dada).should == "waaaa"
92
+ Object.beg(Baby.new, to_say_dada).should == "waaaa"
93
+ beg(Baby.new, to_say_dada).should == "waaaa"
94
+ end
95
+ end
96
+
97
+
27
98
  describe "##bind" do
28
99
  it "should create a new instance method that evaluates the block passed it within the requested closure" do
29
100
  proc do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Parker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-21 00:00:00 -05:00
12
+ date: 2010-02-22 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15