From 2ae026ccbb9fb41e47fe1309d2ff693e27c7243a Mon Sep 17 00:00:00 2001 From: Mark Delk Date: Wed, 23 Sep 2020 12:56:29 -0500 Subject: [PATCH] remove a circular require If applied, this commit removes some circular `require`s. Prior to this change, we had the following circular `require`s ``` require_relative 'entry' unless defined? Net::LDAP::Entry # dataset require_relative 'dataset' unless defined? Net::LDAP::Dataset # entry ``` This works (both classes need each other in methods), but it's unnecessary, since calling `require` twice does nothing, since `$LOADED_FEATURES` has already been updated. This change moves those `require`s to the toplevel, and removes the `defined?` check. --- No tests were added, since the existing tests passed without issue. --- lib/net/ldap/dataset.rb | 4 ++-- lib/net/ldap/entry.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/net/ldap/dataset.rb b/lib/net/ldap/dataset.rb index f7cf96ce..46be4f6f 100644 --- a/lib/net/ldap/dataset.rb +++ b/lib/net/ldap/dataset.rb @@ -1,3 +1,5 @@ +require_relative 'entry' + # -*- ruby encoding: utf-8 -*- ## # An LDAP Dataset. Used primarily as an intermediate format for converting @@ -164,5 +166,3 @@ def read_ldif(io) end end end - -require_relative 'entry' unless defined? Net::LDAP::Entry diff --git a/lib/net/ldap/entry.rb b/lib/net/ldap/entry.rb index 76344540..8eaf4f18 100644 --- a/lib/net/ldap/entry.rb +++ b/lib/net/ldap/entry.rb @@ -1,3 +1,5 @@ +require_relative 'dataset' + # -*- ruby encoding: utf-8 -*- ## # Objects of this class represent individual entries in an LDAP directory. @@ -195,5 +197,3 @@ def setter?(sym) end private :setter? end # class Entry - -require_relative 'dataset' unless defined? Net::LDAP::Dataset