module ActiveLdap::Associations::ClassMethods
def has_many(association_id, options = {})
has_many :members, :class_name => "User",
# :foreign_key => "gidNumber" # Group#gidNumber
# :primary_key => "gidNumber", # User#gidNumber
## are inverted.
## deprecated since 1.1.0. Those options
:foreign_key => "gidNumber" # User#gidNumber
:primary_key => "gidNumber", # Group#gidNumber
has_many :primary_members, :class_name => "User",
Example:
don't exist in LDAP!
This discards any calls which result in entries that
existing multi-element attribute into ActiveLdap objects.
This defines a method for an extension class expand an
has_many
def has_many(association_id, options = {}) validate_has_many_options(options) klass = options[:class] klass ||= (options[:class_name] || association_id.to_s).classify foreign_key = options[:foreign_key] primary_key = options[:primary_key] set_associated_class(association_id, klass) opts = { :association_id => association_id, :foreign_key_name => foreign_key, :primary_key_name => primary_key, :wrap => options[:wrap], :extend => options[:extend], } if opts[:wrap] association_class = Association::HasManyWrap else association_class = Association::HasMany primary_key_name = opts[:primary_key_name] foreign_key_name = opts[:foreign_key_name] if primary_key_name != foreign_key_name and primary_key_name != "dn" and !new.have_attribute?(primary_key_name) message = _(":primary_key and :foreign_key has_many options are " \ "inverted their mean since 1.1.0. Please invert them.") ActiveLdap.deprecator.warn(message) opts[:foreign_key_name] = primary_key_name opts[:primary_key_name] = foreign_key_name end end association_accessor(association_id) do |target| association_class.new(target, opts) end end