Module: Aker::Authorities::Support::FindSoleUser

Included in:
Composite, Ldap::Authority
Defined in:
lib/aker/authorities/support/find_sole_user.rb

Overview

Provides a singular version of the find_users authority method. Authorities which implement that method can mix this in to get find_user for free.

Instance Method Summary collapse

Instance Method Details

#find_user(criteria) ⇒ Aker::User?

Finds the sole user which meets the given criteria. If more than one user meets the criteria, no users are returned.



15
16
17
18
19
20
21
22
# File 'lib/aker/authorities/support/find_sole_user.rb', line 15

def find_user(criteria)
  result = find_users(criteria)
  if result.size == 1
    result.first
  else
    nil
  end
end