bzproxies 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,7 +30,7 @@ module Proxies
30
30
 
31
31
  def respond_to? meth, hidden = false
32
32
  metaclass = class << self; self; end
33
- (metaclass.method_defined? meth) || (@target.respond_to? meth, hidden)
33
+ (metaclass.method_defined? meth) || (__getobj__.respond_to? meth, hidden)
34
34
  end
35
35
 
36
36
  def eql? any
@@ -40,7 +40,7 @@ module Proxies
40
40
  end
41
41
 
42
42
  def == any
43
- (any.respond_to? :proxy?) ? @target == any.target : @target == any
43
+ (any.respond_to? :proxy?) ? __getobj__ == any.__getobj__ : __getobj__ == any
44
44
  end
45
45
 
46
46
  def initialize *args
@@ -57,7 +57,7 @@ module Proxies
57
57
  end
58
58
 
59
59
  def __getobj__
60
- @target
60
+ self.target
61
61
  end
62
62
 
63
63
 
@@ -7,20 +7,20 @@ end
7
7
  class NilClass
8
8
  alias old_equality ==
9
9
  def == any
10
- (any.respond_to? :target) ? old_equality(any.target) : old_equality(any)
10
+ (any.respond_to? :__getobj__) ? old_equality(any.__getobj__) : old_equality(any)
11
11
  end
12
12
  end
13
13
 
14
14
  class TrueClass
15
15
  alias old_equality ==
16
16
  def == any
17
- (any.respond_to? :target) ? old_equality(any.target) : old_equality(any)
17
+ (any.respond_to? :__getobj__) ? old_equality(any.__getobj__) : old_equality(any)
18
18
  end
19
19
  end
20
20
 
21
21
  class FalseClass
22
22
  alias old_equality ==
23
23
  def == any
24
- (any.respond_to? :target) ? old_equality(any.target) : old_equality(any)
24
+ (any.respond_to? :__getobj__) ? old_equality(any.__getobj__) : old_equality(any)
25
25
  end
26
26
  end
@@ -1,3 +1,3 @@
1
1
  module Bzproxies
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/spec/base_spec.rb CHANGED
@@ -93,6 +93,33 @@ describe Proxies::Base do
93
93
  t = Tester.new({:test => {"tatata" => 1}})
94
94
  t["tatata"].should == 1
95
95
  end
96
+
97
+ it "should correctly use __getobj__ with equality and other operations" do
98
+ ["string", 1, false, nil].each do |val|
99
+ a = val
100
+ test1 = Tester.new :test => a
101
+ test2 = Tester.new :test => a
102
+ test3 = Tester.new :test => val
103
+
104
+ (a == test1).should be_true
105
+ (a == test3).should be_true
106
+ (test1 == a).should be_true
107
+ (test3 == a).should be_true
108
+
109
+ a.should_not be_eql test1
110
+ (test1.eql? a).should be_false
111
+
112
+ (test1 == test2).should be_true
113
+ (test2 == test1).should be_true
114
+ (test1 == test3).should be_true
115
+ (test3 == test1).should be_true
116
+
117
+ (test1.eql? test2).should be_true
118
+ (test2.eql? test1).should be_true
119
+ (test1.eql? test3).should be_true
120
+ (test3.eql? test1).should be_true
121
+ end
122
+ end
96
123
 
97
124
 
98
125
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bzproxies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: