Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
Log attributes after coercion
Browse files Browse the repository at this point in the history
In addition to more accurately conveying what strings are committed to
the database, this also makes it possible to copy and paste log messages
right into IRB.
  • Loading branch information
tpope committed Jan 28, 2011
1 parent a1efa13 commit f40e1ca
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/ldaptic/methods.rb
Expand Up @@ -248,19 +248,21 @@ def normalize_attributes(attributes)

# Performs an LDAP add.
def add(dn, attributes)
log_dispatch(:add, dn, attributes)
attributes = normalize_attributes(attributes)
log_dispatch(:add, dn, attributes)
adapter.add(dn, attributes)
end

# Performs an LDAP modify.
def modify(dn, attributes)
log_dispatch(:modify, dn, attributes)
if attributes.kind_of?(Hash)
attributes = normalize_attributes(attributes)
else
attributes = attributes.map {|(action, key, values)| [action, Ldaptic.encode(key), Array(values)]}
attributes = attributes.map do |(action, key, values)|
[action, Ldaptic.encode(key), values.respond_to?(:before_type_cast) ? values.before_type_cast : Array(values)]
end
end
log_dispatch(:modify, dn, attributes)
adapter.modify(dn, attributes) unless attributes.empty?
end

Expand Down

0 comments on commit f40e1ca

Please sign in to comment.