Skip to content

Commit 8c4b201

Browse files
Merge pull request #381 from erlliam/master
Implement '==' operator for entries
2 parents d60bb76 + 9bf26d3 commit 8c4b201

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/net/ldap/entry.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,8 @@ def setter?(sym)
196196
sym.to_s[-1] == ?=
197197
end
198198
private :setter?
199+
200+
def ==(other)
201+
other.instance_of?(self.class) && @myhash == other.to_h
202+
end
199203
end # class Entry

test/test_entry.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ def test_to_h
5454
duplicate.delete(:sn)
5555
assert_not_equal duplicate, @entry.to_h
5656
end
57+
58+
def test_equal_operator
59+
entry_two = Net::LDAP::Entry.new 'cn=Barbara,o=corp'
60+
assert_equal @entry, entry_two
61+
62+
@entry['sn'] = 'Jensen'
63+
assert_not_equal @entry, entry_two
64+
65+
entry_two['sn'] = 'Jensen'
66+
assert_equal @entry, entry_two
67+
end
5768
end
5869

5970
class TestEntryLDIF < Test::Unit::TestCase

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy