Class: ProfilePresenter

Inherits:
BasePresenter show all
Includes:
PeopleHelper
Defined in:
app/presenters/profile_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_user

Instance Method Summary collapse

Methods included from PeopleHelper

#birthday_format, #local_or_remote_person_path, #person_image_link, #person_image_tag, #person_link, #search_header

Methods inherited from BasePresenter

as_collection, #initialize, #method_missing, new

Constructor Details

This class inherits a constructor from BasePresenter

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BasePresenter

Instance Method Details

#as_other_api_json(all_details) ⇒ Object


35
36
37
38
39
# File 'app/presenters/profile_presenter.rb', line 35

def as_other_api_json(all_details)
  return base_api_json unless all_details

  base_api_json.merge(added_details_api_json)
end

#as_self_api_jsonObject


27
28
29
30
31
32
33
# File 'app/presenters/profile_presenter.rb', line 27

def as_self_api_json
  base_api_json.merge(added_details_api_json).merge(
    searchable:        searchable,
    show_profile_info: public_details,
    nsfw:              nsfw
  )
end

#base_hashObject


6
7
8
9
10
11
# File 'app/presenters/profile_presenter.rb', line 6

def base_hash
  {
    id:         id,
    searchable: searchable
  }
end

#for_hovercardObject


20
21
22
23
24
25
# File 'app/presenters/profile_presenter.rb', line 20

def for_hovercard
  {
    avatar: AvatarPresenter.new(@presentable).medium,
    tags:   tags.pluck(:name)
  }
end

#formatted_birthdayObject


50
51
52
# File 'app/presenters/profile_presenter.rb', line 50

def formatted_birthday
  birthday_format(birthday) if birthday
end

#private_hashObject


41
42
43
44
45
46
47
48
# File 'app/presenters/profile_presenter.rb', line 41

def private_hash
  public_hash.merge(
    bio:      bio_message.plain_text_for_json,
    birthday: formatted_birthday,
    gender:   gender,
    location: location_message.plain_text_for_json
  )
end

#public_hashObject


13
14
15
16
17
18
# File 'app/presenters/profile_presenter.rb', line 13

def public_hash
  base_hash.merge(
    avatar: AvatarPresenter.new(@presentable).base_hash(true),
    tags:   tags.pluck(:name)
  )
end