From 3d43b3a459697d74b5d46c7e49b81dbb17d78aec Mon Sep 17 00:00:00 2001 From: Erlliam Mejia Date: Wed, 14 Oct 2020 12:56:18 -0400 Subject: [PATCH 1/2] Implement '==' operator for entries --- lib/net/ldap/entry.rb | 4 ++++ test/test_entry.rb | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/net/ldap/entry.rb b/lib/net/ldap/entry.rb index 8eaf4f18..63b8ee16 100644 --- a/lib/net/ldap/entry.rb +++ b/lib/net/ldap/entry.rb @@ -196,4 +196,8 @@ def setter?(sym) sym.to_s[-1] == ?= end private :setter? + + def ==(other) + return other.instance_of?(self.class) && @myhash == other.to_h + end end # class Entry diff --git a/test/test_entry.rb b/test/test_entry.rb index 7c440ddf..60c89ba6 100644 --- a/test/test_entry.rb +++ b/test/test_entry.rb @@ -54,6 +54,17 @@ def test_to_h duplicate.delete(:sn) assert_not_equal duplicate, @entry.to_h end + + def test_equal_operator + entry_two = Net::LDAP::Entry.new 'cn=Barbara,o=corp' + assert_equal @entry, entry_two + + @entry['sn'] = 'Jensen' + assert_not_equal @entry, entry_two + + entry_two['sn'] = 'Jensen' + assert_equal @entry, entry_two + end end class TestEntryLDIF < Test::Unit::TestCase From 9bf26d346838e319d6d129b119c0a08eee626f86 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Wed, 28 Oct 2020 23:29:54 -0400 Subject: [PATCH 2/2] Update lib/net/ldap/entry.rb --- lib/net/ldap/entry.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/net/ldap/entry.rb b/lib/net/ldap/entry.rb index 63b8ee16..8e71b389 100644 --- a/lib/net/ldap/entry.rb +++ b/lib/net/ldap/entry.rb @@ -198,6 +198,6 @@ def setter?(sym) private :setter? def ==(other) - return other.instance_of?(self.class) && @myhash == other.to_h + other.instance_of?(self.class) && @myhash == other.to_h end end # class Entry 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