Module: UserMixins::Identification::ClassMethods

Defined in:
app/models/user_mixins/identification.rb

Instance Method Summary collapse

Instance Method Details

#attributes_used_for_identificationObject

The user may identify himself using one of these attributes.



17
18
19
# File 'app/models/user_mixins/identification.rb', line 17

def attributes_used_for_identification
  [ :alias, :last_name, :name, :email ]
end

#find_all_by_identification_string(identification_string) ⇒ Object

Find all users where the identification string matches one of the attributes given by ‘attributes_used_for_identification`.

This method returns an array of users matching the given login string. In contrast to ‘self.identify`, this returns an array, whereas `self.identify` returns a user object if the match was unique.



28
29
30
31
32
33
34
35
# File 'app/models/user_mixins/identification.rb', line 28

def find_all_by_identification_string( identification_string )
  (
    User.where(alias: identification_string) +
    User.where(last_name: identification_string) +
    User.find_all_by_name(identification_string) +
    User.find_all_by_email(identification_string)
  ).uniq
end