Class: Workarea::Search::UserText

Inherits:
Object
  • Object
show all
Defined in:
app/models/workarea/search/user_text.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ UserText

Returns a new instance of UserText.



4
5
6
# File 'app/models/workarea/search/user_text.rb', line 4

def initialize(user)
  @user = user
end

Instance Method Details

#addresses_textObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/workarea/search/user_text.rb', line 20

def addresses_text
  (@user.addresses || []).map do |address|
    [
      address.street,
      address.street_2,
      address.city,
      address.region,
      address.region_name,
      address.postal_code,
      address.country.name,
      address.country.alpha2,
      address.phone_number
    ].join(' ')
  end
end

#textObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/workarea/search/user_text.rb', line 8

def text
  [
    'user people',
    @user.email,
    @user.first_name,
    @user.last_name,
    @user.tags,
    addresses_text,
    type_text
  ].flatten.join(' ')
end

#type_textObject



36
37
38
39
40
41
42
# File 'app/models/workarea/search/user_text.rb', line 36

def type_text
  if @user.admin?
    'admin administrator'
  else
    'customer'
  end
end