commit ed02e3985f4e1887909846a88b8f18e134cdb753
Author: Marc Dequènes (Duck) <Duck@DuckCorp.org>
Date:   Mon Jul 20 02:22:55 2009 +0200

    [evol] associations are in fact relations, added primaryGroup relation

diff --git a/config/test.conf b/config/test.conf
index aa581cb..34ced3b 100644
--- a/config/test.conf
+++ b/config/test.conf
@@ -12,7 +12,12 @@ objects:
       allowed_aspects: ['mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
       hidden_attributes: ['objectClass']
       expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
-    associations:
+    relations:
+      primaryGroup:
+        type: :has_many
+        object: group
+        foreign_key: gidNumber
+        primary_key: gidNumber
       secondaryGroups:
         type: :belongs_to
         object: group
@@ -30,7 +35,12 @@ objects:
       allowed_aspects: ['mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
       hidden_attributes: ['objectClass']
       expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
-    associations:
+    relations:
+      primaryGroup:
+        type: :has_many
+        object: group
+        foreign_key: gidNumber
+        primary_key: gidNumber
       secondaryGroups:
         type: :belongs_to
         object: group
@@ -48,7 +58,7 @@ objects:
       allowed_aspects: []
       hidden_attributes: ['objectClass']
       expert_attributes: ['gidNumber']
-    associations:
+    relations:
       individuals:
         type: :has_many
         object: individual
@@ -64,35 +74,35 @@ aspects:
     mapping:
       classes: ['emailUser']
     presentation:
-    associations:
+    relations:
   fs:
     mapping:
       classes: ['fsUser']
     presentation:
-    associations:
+    relations:
   shell:
     mapping:
       classes: ['shellUser']
     presentation:
       associated_attributes: ['loginShell']
-    associations:
+    relations:
   ftp:
     mapping:
       classes: ['ftpUser']
     presentation:
-    associations:
+    relations:
   web:
     mapping:
       classes: ['webUser']
     presentation:
-    associations:
+    relations:
   jabber:
     mapping:
       classes: ['jabberUser']
     presentation:
-    associations:
+    relations:
   primary:
     mapping:
       classes: ['primaryAccount']
     presentation:
-    associations:
+    relations:
diff --git a/locale/en.yml b/locale/en.yml
index 6ea3f4a..5e372a8 100644
--- a/locale/en.yml
+++ b/locale/en.yml
@@ -32,7 +32,7 @@ en:
     uidNumber: "Identifier (numeric)"
     uniqueMember: "Group member"
     webVirtualHost: "Hosted Web Sites"
-  associations:
+  relations:
     primaryGroup: "Primary Group"
     secondaryGroups: "Secondary Groups"
   aspects:
diff --git a/test.rb b/test.rb
index b2a430d..bf423d1 100755
--- a/test.rb
+++ b/test.rb
@@ -52,6 +52,8 @@ module LdapMapper
       return ""
     end
 
+    alias :relations :associations
+
     def aspects
       present_aspects = []
       self.class.presentation[:allowed_aspects].each do |aspect|
@@ -90,7 +92,7 @@ module LdapMapper
 
       aspects = self.aspects
 
-      # first pass to take aspects forced associations into account
+      # first pass to take aspects forced relations into account
       obj_aspects = {}
       aspects.each do |aspect|
         aspect_data = self.class.mapper.get_aspect(aspect)
@@ -169,7 +171,7 @@ module LdapMapper
       klass.mapper = self
       klass.ldap_mapping obj_mapping.reject {|key, val| not ActiveLdap::Base::VALID_LDAP_MAPPING_OPTIONS.include?(key) }
 
-      # store definition for later associations processing
+      # store definition for later relations processing
       @object_definitions[obj_name] = obj_def
     end
 
@@ -180,24 +182,24 @@ module LdapMapper
     end
 
     # run it _once_ when all objects are loaded
-    def load_associations
+    def load_relations
       @object_definitions.each_pair do |obj_name, obj_def|
-        next unless obj_def.include?(:associations)
-        obj_assoc = obj_def[:associations]
+        next unless obj_def.include?(:relations)
+        obj_rel = obj_def[:relations]
 
         klass = find_klass(obj_name)
 
-        obj_assoc.each_pair do |field_name, assoc|
-          foreign_klass = find_klass(assoc[:object])
-          assoc[:class_name] = foreign_klass.to_s
+        obj_rel.each_pair do |field_name, rel|
+          foreign_klass = find_klass(rel[:object])
+          rel[:class_name] = foreign_klass.to_s
 
-          case assoc[:type]
+          case rel[:type]
           when :belongs_to
-            klass.belongs_to field_name, assoc.reject {|key, val| not ActiveLdap::Associations::ClassMethods::VALID_BELONGS_TO_OPTIONS.include?(key) }
+            klass.belongs_to field_name, rel.reject {|key, val| not ActiveLdap::Associations::ClassMethods::VALID_BELONGS_TO_OPTIONS.include?(key) }
           when :has_many
-            klass.has_many field_name, assoc.reject {|key, val| not ActiveLdap::Associations::ClassMethods::VALID_HAS_MANY_OPTIONS.include?(key) }
+            klass.has_many field_name, rel.reject {|key, val| not ActiveLdap::Associations::ClassMethods::VALID_HAS_MANY_OPTIONS.include?(key) }
           else
-            raise "bug in '#{obj_name}' object associations (wrong type)"
+            raise "bug in '#{obj_name}' object relations (wrong type)"
           end
         end
       end
@@ -220,7 +222,7 @@ end
 config[:objects].each_pair do |obj_name, obj_data|
   ldapctl.load_object(obj_name, obj_data)
 end
-ldapctl.load_associations
+ldapctl.load_relations
 
 cmd = CmdParse::Command.new('list', false)
 cmd.short_desc = "list objects"
@@ -309,10 +311,10 @@ cmd.set_execution_block do |args|
     end
   end
 
-  puts "=== Associations ==="
-  item.associations.each do |assoc|
-    assoc_display_name = I18n.t(assoc, :scope => 'associations', :default => assoc.to_s)
-    puts "#{assoc_display_name}: " + item.send(assoc).collect{|g| g.name }.join(", ")
+  puts "=== Relations ==="
+  item.relations.each do |rel|
+    rel_display_name = I18n.t(rel, :scope => 'relations', :default => rel.to_s)
+    puts "#{rel_display_name}: " + item.send(rel).collect{|g| g.name }.join(", ")
   end
 end
 cmdparser.add_command(cmd)
