Sha256: d4475329cda4efeefd2bd217fc19a1191d6d3a342896e58941c23ac6402d4b33
Contents?: true
Size: 747 Bytes
Versions: 2
Compression:
Stored size: 747 Bytes
Contents
require "database_cleaner/strategy" module DatabaseCleaner module Ldap class Deletion < DatabaseCleaner::Strategy attr_reader :filter def initialize(opts={}) raise ArgumentError, "Option :filter must be a Net::LDAP::Filter" unless opts.empty? || opts[:filter].is_a?(Net::LDAP::Filter) @filter = opts[:filter] end def clean entries.each { |ldap_entry| delete! ldap_entry.dn } end def db @db ||= Net::LDAP.new end private def entries Array db.search(filter: filter) end def delete!(dn) db.delete(dn: dn) or raise "Could no delete #{dn}. Reason: #{db.get_operation_result}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
database_cleaner-ldap-0.2.0 | lib/database_cleaner/ldap/deletion.rb |
database_cleaner-ldap-0.1.0 | lib/database_cleaner/ldap/deletion.rb |