forwardablex 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # History of ForwardableX
2
2
 
3
+ ## 0.1.2
4
+
5
+ * Bug fix: proc receivers should be evaluated in context of instance.
6
+
3
7
  ## 0.1.1
4
8
 
5
9
  * Introduced receiver keyword :class for forwarding to class method
data/lib/forwardablex.rb CHANGED
@@ -66,7 +66,7 @@ module ForwardableX
66
66
  end
67
67
  when Proc
68
68
  define_method(name) do |*args, &b|
69
- receiver.call.__send__(method, *args, &b)
69
+ instance_eval(&receiver).__send__(method, *args, &b)
70
70
  end
71
71
  else
72
72
  define_method(name) do |*args, &b|
@@ -1,4 +1,4 @@
1
1
  module ForwardableX
2
2
  # version of ForwardableX
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
@@ -20,9 +20,9 @@ class XForwarder < Forwarder
20
20
  forward :@rec, :m1
21
21
  forward :@rec, :m1, :mm1
22
22
  forward! :@rec, :m2, :m3
23
- forward Proc.new{Receiver.new}, :m4
24
- forward Proc.new{Receiver.new}, :m4, :mm4
25
- forward! Proc.new{Receiver.new}, :m5, :m6
23
+ forward Proc.new{@rec}, :m4
24
+ forward Proc.new{@rec}, :m4, :mm4
25
+ forward! Proc.new{@rec}, :m5, :m6
26
26
  forward Receiver.new, :m7
27
27
  forward Receiver.new, :m7, :mm7
28
28
  forward! Receiver.new, :m8, :m9
@@ -32,9 +32,9 @@ class DefDelegatorForwarder < Forwarder
32
32
  def_delegator :@rec, :m1
33
33
  def_delegator :@rec, :m1, :mm1
34
34
  def_delegators :@rec, :m2, :m3
35
- def_delegator Proc.new{Receiver.new}, :m4
36
- def_delegator Proc.new{Receiver.new}, :m4, :mm4
37
- def_delegators Proc.new{Receiver.new}, :m5, :m6
35
+ def_delegator Proc.new{@rec}, :m4
36
+ def_delegator Proc.new{@rec}, :m4, :mm4
37
+ def_delegators Proc.new{@rec}, :m5, :m6
38
38
  def_delegator Receiver.new, :m7
39
39
  def_delegator Receiver.new, :m7, :mm7
40
40
  def_delegators Receiver.new, :m8, :m9
@@ -44,9 +44,9 @@ class DefInstanceDelegatorForwarder < Forwarder
44
44
  def_instance_delegator :@rec, :m1
45
45
  def_instance_delegator :@rec, :m1, :mm1
46
46
  def_instance_delegators :@rec, :m2, :m3
47
- def_instance_delegator Proc.new{Receiver.new}, :m4
48
- def_instance_delegator Proc.new{Receiver.new}, :m4, :mm4
49
- def_instance_delegators Proc.new{Receiver.new}, :m5, :m6
47
+ def_instance_delegator Proc.new{@rec}, :m4
48
+ def_instance_delegator Proc.new{@rec}, :m4, :mm4
49
+ def_instance_delegators Proc.new{@rec}, :m5, :m6
50
50
  def_instance_delegator Receiver.new, :m7
51
51
  def_instance_delegator Receiver.new, :m7, :mm7
52
52
  def_instance_delegators Receiver.new, :m8, :m9
@@ -55,8 +55,8 @@ end
55
55
  class DelegateForwarder < Forwarder
56
56
  delegate :m1 => :@rec
57
57
  delegate [:m2, :m3] => :@rec
58
- delegate :m4 => Proc.new{Receiver.new}
59
- delegate [:m5, :m6] => Proc.new{Receiver.new}
58
+ delegate :m4 => Proc.new{@rec}
59
+ delegate [:m5, :m6] => Proc.new{@rec}
60
60
  delegate :m7 => Receiver.new
61
61
  delegate [:m8, :m9] => Receiver.new
62
62
  end
@@ -66,9 +66,9 @@ xforwarder = Forwarder.new("xforwarder").tap do |obj|
66
66
  obj.forward :@rec, :m1
67
67
  obj.forward :@rec, :m1, :mm1
68
68
  obj.forward! :@rec, :m2, :m3
69
- obj.forward Proc.new{Receiver.new}, :m4
70
- obj.forward Proc.new{Receiver.new}, :m4, :mm4
71
- obj.forward! Proc.new{Receiver.new}, :m5, :m6
69
+ obj.forward Proc.new{@rec}, :m4
70
+ obj.forward Proc.new{@rec}, :m4, :mm4
71
+ obj.forward! Proc.new{@rec}, :m5, :m6
72
72
  obj.forward Receiver.new, :m7
73
73
  obj.forward Receiver.new, :m7, :mm7
74
74
  obj.forward! Receiver.new, :m8, :m9
@@ -79,9 +79,9 @@ singletonforwarder = Forwarder.new("singletonforwarder").tap do |obj|
79
79
  obj.def_singleton_delegator :@rec, :m1
80
80
  obj.def_singleton_delegator :@rec, :m1, :mm1
81
81
  obj.def_singleton_delegators :@rec, :m2, :m3
82
- obj.def_singleton_delegator Proc.new{Receiver.new}, :m4
83
- obj.def_singleton_delegator Proc.new{Receiver.new}, :m4, :mm4
84
- obj.def_singleton_delegators Proc.new{Receiver.new}, :m5, :m6
82
+ obj.def_singleton_delegator Proc.new{@rec}, :m4
83
+ obj.def_singleton_delegator Proc.new{@rec}, :m4, :mm4
84
+ obj.def_singleton_delegators Proc.new{@rec}, :m5, :m6
85
85
  obj.def_singleton_delegator Receiver.new, :m7
86
86
  obj.def_singleton_delegator Receiver.new, :m7, :mm7
87
87
  obj.def_singleton_delegators Receiver.new, :m8, :m9
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forwardablex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-06 00:00:00.000000000 Z
12
+ date: 2013-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
- rubygems_version: 1.8.24
99
+ rubygems_version: 1.8.25
100
100
  signing_key:
101
101
  specification_version: 3
102
102
  summary: Forwardable extension