Class: TestingNotePresenter

Inherits:
Object
  • Object
show all
Includes:
AvatarHelper
Defined in:
app/presenters/testing_note_presenter.rb

Instance Method Summary collapse

Methods included from AvatarHelper

#avatar_for, #gravatar_image, #gravatar_url

Constructor Details

#initialize(testing_notes) ⇒ TestingNotePresenter

Returns a new instance of TestingNotePresenter.



4
5
6
# File 'app/presenters/testing_note_presenter.rb', line 4

def initialize(testing_notes)
  @testing_notes = testing_notes
end

Instance Method Details

#as_json(*args) ⇒ Object



8
9
10
11
12
13
14
# File 'app/presenters/testing_note_presenter.rb', line 8

def as_json(*args)
  if @testing_notes.is_a?(TestingNote)
    to_hash @testing_notes
  else
    @testing_notes.map(&method(:to_hash))
  end
end

#to_hash(testing_note) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'app/presenters/testing_note_presenter.rb', line 16

def to_hash(testing_note)
  { id: testing_note.id,
    createdAt: testing_note.created_at,
    avatarImage: avatar_for(testing_note.user),
    userId: testing_note.user_id,
    byTester: testing_note.user.try(:tester?),
    ticketId: testing_note.ticket_id,
    verdict: testing_note.verdict,
    comment: testing_note.comment }
end