commit 3e7f80c01ca7c5a2baf5b3ddbf8148e02ea026dc
Author: Marc Dequènes (Duck) <Duck@DuckCorp.org>
Date:   Fri Oct 23 01:18:47 2009 +0200

    [cleanup] code reorganization

diff --git a/lib/ldap_shadows/activeldap_fixes.rb b/lib/ldap_shadows/activeldap_fixes.rb
index b08cc58..c271ae3 100644
--- a/lib/ldap_shadows/activeldap_fixes.rb
+++ b/lib/ldap_shadows/activeldap_fixes.rb
@@ -38,8 +38,18 @@ module ActiveLdap
     end
   end
 
-  # patch for activeldap#26745
   class Base
+    # temporary method until active_ldap is fixed: return a DN object (see activeldap#23932)
+    def dn_obj
+      ActiveLdap::DistinguishedName.parse(self.dn)
+    end
+
+    # temporary method until active_ldap is fixed: return a DN object (see activeldap#23932)
+    def self.base_obj
+      ActiveLdap::DistinguishedName.parse(self.base)
+    end
+
+    # patch for activeldap#26745
     def collect_modified_attributes(ldap_data, data)
       attributes = []
       # Now that all the options will be treated as unique attributes
diff --git a/lib/ldap_shadows/elements/object.rb b/lib/ldap_shadows/elements/object.rb
index 2474b1f..9e586f6 100755
--- a/lib/ldap_shadows/elements/object.rb
+++ b/lib/ldap_shadows/elements/object.rb
@@ -78,16 +78,6 @@ module Elements
       instance_variable_set(:@relations_info, object_relations_info)
     end
 
-    # temporary method until active_ldap is fixed: return a DN object (see activeldap#23932)
-    def dn_obj
-      ActiveLdap::DistinguishedName.parse(self.dn)
-    end
-
-    # temporary method until active_ldap is fixed: return a DN object (see activeldap#23932)
-    def self.base_obj
-      ActiveLdap::DistinguishedName.parse(self.base)
-    end
-
     def name
       name = self[dn_attribute] || self.attributes[dn_attribute] || self.dn
       name = name[0] if name.is_a? Array
@@ -160,21 +150,6 @@ module Elements
       present_aspects
     end
 
-    def self.objectclasses_attr_list(objectclass_list)
-      objectclass_list = [objectclass_list] unless objectclass_list.is_a? Array
-      list = []
-      objectclass_list.each do |objectclass|
-        objectclass_obj = ActiveLdap::Base.schema.object_class(objectclass)
-        attr_list = objectclass_obj.must + objectclass_obj.may
-        list += attr_list.collect{|attr| attr.human_attribute_name }
-      end
-      list
-    end
-
-    def self.possible_attributes
-      self.objectclasses_attr_list(self.required_classes)
-    end
-
     def self.possible_attributes_for_aspect(aspect)
       self.objectclasses_attr_list(self.shadow.get_aspect(aspect).parameters[:mapping][:classes])
     end
@@ -551,60 +526,6 @@ module Elements
       end
     end
 
-    def family_parent_dn
-      pdn = self.dn_obj.dup
-      pdn.shift
-      pdn
-    end
-
-    def family_parent
-      # nothing found when using LdapObject, that's weird, so using ActiveLdap::Base
-      # until further investigation
-      #LdapObject.find(:first, :base => self.family_parent_dn.to_s, :scope => :base)
-      ActiveLdap::Base.find(:first, :base => self.family_parent_dn.to_s, :scope => :base)
-    end
-
-    def family_children
-      LdapObject.find(:all, :base => self.dn, :scope => :one)
-    end
-
-    def family_children_dn
-      self.family_children.collect {|obj| obj.dn }
-    end
-
-    def family_siblings
-      # cannot substract, as the ruby object signature may be different
-      LdapObject.find(:all, :base => self.family_parent_dn.to_s, :scope => :one).select{|obj| obj.dn != self.dn }
-    end
-
-    def family_siblings_dn
-      self.family_siblings.collect {|obj| obj.dn }
-    end
-
-    def modified_attributes(op_types = nil, att_only = false)
-      list = []
-      prepare_data_for_saving do |data, ldap_data|
-        list = collect_modified_attributes(ldap_data, data)
-        false
-      end
-
-      unless op_types.nil?
-        list.reject! do |mod_info|
-          op_type, att, new_val = mod_info
-          not op_types.include? op_type
-        end
-      end
-
-      if att_only
-        list.collect! do |mod_info|
-          op_type, att, new_val = mod_info
-          att
-        end
-      end
-
-      list
-    end
-
     def add_aspect(aspect)
       return unless self.class.possible_aspects.include?(aspect)
 
diff --git a/lib/ldap_shadows/lang_additions.rb b/lib/ldap_shadows/lang_additions.rb
index 0d92866..2655048 100644
--- a/lib/ldap_shadows/lang_additions.rb
+++ b/lib/ldap_shadows/lang_additions.rb
@@ -32,5 +32,72 @@ module ActiveLdap
       @rdns.shift
     end
   end
+
+  class Base
+    def family_parent_dn
+      pdn = self.dn_obj.dup
+      pdn.shift
+      pdn
+    end
+
+    def family_parent
+      ActiveLdap::Base.find(:first, :base => self.family_parent_dn.to_s, :scope => :base)
+    end
+
+    def family_children
+      ActiveLdap::Base.find(:all, :base => self.dn, :scope => :one)
+    end
+
+    def family_children_dn
+      self.family_children.collect {|obj| obj.dn }
+    end
+
+    def family_siblings
+      ActiveLdap::Base.find(:all, :base => self.family_parent_dn.to_s, :scope => :one).select{|obj| obj.dn != self.dn }
+    end
+
+    def family_siblings_dn
+      self.family_siblings.collect {|obj| obj.dn }
+    end
+
+    def modified_attributes(op_types = nil, att_only = false)
+      list = []
+      prepare_data_for_saving do |data, ldap_data|
+        list = collect_modified_attributes(ldap_data, data)
+        false
+      end
+
+      unless op_types.nil?
+        list.reject! do |mod_info|
+          op_type, att, new_val = mod_info
+          not op_types.include? op_type
+        end
+      end
+
+      if att_only
+        list.collect! do |mod_info|
+          op_type, att, new_val = mod_info
+          att
+        end
+      end
+
+      list
+    end
+
+    def self.objectclasses_attr_list(objectclass_list)
+      objectclass_list = [objectclass_list] unless objectclass_list.is_a? Array
+      list = []
+      objectclass_list.each do |objectclass|
+        objectclass_obj = ActiveLdap::Base.schema.object_class(objectclass)
+        attr_list = objectclass_obj.must + objectclass_obj.may
+        list += attr_list.collect{|attr| attr.human_attribute_name }
+      end
+      list
+    end
+
+    def self.possible_attributes
+      self.objectclasses_attr_list(self.required_classes)
+    end
+  end
 end
 
