Module: LDAP::Server::MatchingRule::Substrings

Included in:
DefaultMatchingClass
Defined in:
lib/ldap/server/match.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) substrings(vals, *ss)



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/ldap/server/match.rb', line 125

def substrings(vals, *ss)
  return false if vals.nil?

  # convert the condition list into a regexp
  re = []
  re << "^#{Regexp.escape(normalize(ss[0]).to_s)}" if ss[0]
  ss[1..-2].each { |s| re << Regexp.escape(normalize(s).to_s) }
  re << "#{Regexp.escape(normalize(ss[-1]).to_s)}$" if ss[-1]
  re = Regexp.new(re.join(".*"))

  vals.each do |v|
    v = normalize(v).to_s
    return true if re.match(v)
  end
  return false
end