Class: ConversationPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/conversation_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_user

Instance Method Summary collapse

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_api_jsonObject


4
5
6
7
8
9
10
11
12
13
# File 'app/presenters/conversation_presenter.rb', line 4

def as_api_json
  read = @presentable.conversation_visibilities.find_by(person_id: current_user.person_id)&.unread == 0
  {
    guid:         @presentable.guid,
    subject:      @presentable.subject,
    created_at:   @presentable.created_at,
    read:         read,
    participants: @presentable.participants.map {|x| PersonPresenter.new(x).as_api_json }
  }
end