search_index.rb 643 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. module User::SearchIndex
  3. =begin
  4. get data to store in search index
  5. user = User.find(123)
  6. result = user.search_index_data
  7. returns
  8. result = true # false
  9. =end
  10. def search_index_data
  11. attributes = { 'fullname' => "#{ self['firstname'] } #{ self['lastname'] }" }
  12. ['login', 'firstname', 'lastname', 'phone', 'email', 'city', 'country', 'note', 'created_at'].each { |key|
  13. if self[key] && (!self.respond_to?('empty?') || !self[key].empty?)
  14. attributes[key] = self[key]
  15. end
  16. }
  17. return if attributes.empty?
  18. attributes
  19. end
  20. end