commit accc97fc6c0f1be28509ccdb5681471c097b6b6e
Author: Marc Dequènes (Duck) <Duck@DuckCorp.org>
Date:   Fri Oct 23 00:37:35 2009 +0200

    [cleanup] simplifications thanks to default config

diff --git a/lib/ldap_shadows/elements/aspect.rb b/lib/ldap_shadows/elements/aspect.rb
index f6f5c31..85bc9a4 100644
--- a/lib/ldap_shadows/elements/aspect.rb
+++ b/lib/ldap_shadows/elements/aspect.rb
@@ -25,7 +25,7 @@ module Elements
     def self.cast_relations
       super
 
-      deps = self.parameters[:mapping][:depend_aspects] || []
+      deps = self.parameters[:mapping][:depend_aspects]
       deps.each do |aspect_name|
         aspect = self.shadow.get_aspect(aspect_name)
         if aspect.nil?
diff --git a/lib/ldap_shadows/elements/object.rb b/lib/ldap_shadows/elements/object.rb
index d124f67..b769138 100755
--- a/lib/ldap_shadows/elements/object.rb
+++ b/lib/ldap_shadows/elements/object.rb
@@ -42,15 +42,13 @@ module Elements
 
       object_rel = {}
       object_rel.merge!(self.parameters[:relations]) if self.parameters.include?(:relations)
-      if self.parameters[:presentation].has_key?(:allowed_aspects)
-        self.parameters[:presentation][:allowed_aspects].each do |aspect_name|
-          aspect = self.shadow.get_aspect(aspect_name)
-          if aspect.nil?
-            raise PreProcessingError, _("Aspect '%s' is missing for object '%s'") % [aspect_name, self.handle]
-          end
-          aspect_data = aspect.parameters
-          object_rel.merge!(aspect_data[:relations]) if aspect_data.has_key?(:relations) and aspect_data[:relations]
+      self.parameters[:presentation][:allowed_aspects].each do |aspect_name|
+        aspect = self.shadow.get_aspect(aspect_name)
+        if aspect.nil?
+          raise PreProcessingError, _("Aspect '%s' is missing for object '%s'") % [aspect_name, self.handle]
         end
+        aspect_data = aspect.parameters
+        object_rel.merge!(aspect_data[:relations])
       end
       return if object_rel.empty?
 
@@ -103,7 +101,8 @@ module Elements
 
     def human_name
       attr_list = ['displayName', 'cn']
-      attr_list.unshift(self.class.parameters[:presentation][:name_attribute]) if self.class.parameters[:presentation].has_key?(:name_attribute)
+      name_attribute = self.class.parameters[:presentation][:name_attribute]
+      attr_list.unshift(name_attribute) unless name_attribute.nil?
       attr_list.each do |attr|
         if attr == 'dn'
           return self.dn
@@ -117,7 +116,8 @@ module Elements
 
     def human_description
       attr_list = ['description']
-      attr_list.unshift(self.class.parameters[:presentation][:desc_attribute]) if self.class.parameters[:presentation].has_key?(:desc_attribute)
+      desc_attribute = self.class.parameters[:presentation][:desc_attribute]
+      attr_list.unshift(desc_attribute) unless desc_attribute.nil?
       attr_list.each do |attr|
         if self.attribute_present?(attr)
           return self[attr].is_a?(Array) ? self[attr][0] : self[attr]
@@ -152,7 +152,7 @@ module Elements
 
     def aspects
       present_aspects = []
-      (self.class.parameters[:presentation][:allowed_aspects] || []).each do |aspect|
+      self.class.parameters[:presentation][:allowed_aspects].each do |aspect|
         aspect_data = self.class.shadow.get_aspect(aspect).parameters
         aspect_mapping = aspect_data[:mapping]
         present_aspects << aspect if self.classes & aspect_mapping[:classes] == aspect_mapping[:classes]
@@ -188,11 +188,11 @@ module Elements
     end
 
     def organized_data
-      ignored_attrs = self.class.shadow.get_config[:presentation][:hidden_attributes] || []
-      ignored_attrs += self.class.parameters[:presentation][:hidden_attributes] || []
+      ignored_attrs = self.class.shadow.get_config[:presentation][:hidden_attributes]
+      ignored_attrs += self.class.parameters[:presentation][:hidden_attributes]
       attr_list = self.nonempty_attributes - ignored_attrs
 
-      expert_attributes = (self.class.parameters[:presentation][:expert_attributes] || [])
+      expert_attributes = self.class.parameters[:presentation][:expert_attributes]
       admin_attributes = attr_list.select do |attr|
         ActiveLdap::Base.schema.attribute(attr).operational?
       end
@@ -230,9 +230,7 @@ module Elements
         taken_attr_list = attr_list
       else
         taken_attr_list = admin_attributes
-        if self.class.parameters[:presentation].has_key?(:associated_attributes)
-          taken_attr_list += self.class.parameters[:presentation][:associated_attributes]
-        end
+        taken_attr_list += self.class.parameters[:presentation][:associated_attributes]
         taken_attr_list += self.class.possible_attributes
       end
       taken_attr_list = taken_attr_list.uniq & attr_list
@@ -616,8 +614,7 @@ module Elements
       add_class(*aspect_data[:mapping][:classes])
 
       # recursive dependency enforcement
-      depends = aspect_data[:mapping][:depend_aspects] || []
-      depends.each do |dep_aspect|
+      aspect_data[:mapping][:depend_aspects].each do |dep_aspect|
         add_aspect(dep_aspect)
       end
     end
diff --git a/lib/ldap_shadows/shadow.rb b/lib/ldap_shadows/shadow.rb
index 324a518..57c9880 100755
--- a/lib/ldap_shadows/shadow.rb
+++ b/lib/ldap_shadows/shadow.rb
@@ -111,7 +111,7 @@ module LdapShadows
            item_list[ActiveLdap::DistinguishedName.parse(item.dn)]= item
         end
       else
-        (self.get_config[:presentation][:tree_objects] || []).each do |obj_hdl|
+        self.get_config[:presentation][:tree_objects].each do |obj_hdl|
           obj_klass = get_object(obj_hdl.downcase)
           unless obj_klass
             raise PreProcessingError, _("Tree object '%s' not defined") % obj_hdl
