module ActiveLdap::Attributes::ClassMethods

def blank_value?(value)

def blank_value?(value)
  case value
  when Hash
    value.values.all? {|val| blank_value?(val)}
  when Array
    value.all? {|val| blank_value?(val)}
  when String
    /\A\s*\z/ === value
  when true, false
    false
  when nil
    true
  else
    value.blank?
  end
end

def remove_blank_value(value)

def remove_blank_value(value)
  case value
  when Hash
    result = {}
    value.each do |k, v|
      v = remove_blank_value(v)
      next if v.nil?
      result[k] = v
    end
    result = nil if result.blank?
    result
  when Array
    result = []
    value.each do |v|
      v = remove_blank_value(v)
      next if v.nil?
      result << v
    end
    result = nil if result.blank?
    result
  when String
    if /\A\s*\z/ =~ value
      nil
    else
      value
    end
  else
    value
  end
end