Class: Renalware::Letters::UnreadElectronicCCsComponent

Inherits:
ApplicationComponent
  • Object
show all
Defined in:
app/components/renalware/letters/unread_electronic_ccs_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationComponent

#policy, #renalware

Constructor Details

#initialize(current_user:) ⇒ UnreadElectronicCCsComponent

Returns a new instance of UnreadElectronicCCsComponent.



8
9
10
# File 'app/components/renalware/letters/unread_electronic_ccs_component.rb', line 8

def initialize(current_user:)
  @current_user = current_user
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



6
7
8
# File 'app/components/renalware/letters/unread_electronic_ccs_component.rb', line 6

def current_user
  @current_user
end

Instance Method Details

#unread_electronic_ccsObject



12
13
14
15
16
17
18
19
20
21
# File 'app/components/renalware/letters/unread_electronic_ccs_component.rb', line 12

def unread_electronic_ccs
  @unread_electronic_ccs ||= begin
    receipts = Letters::ElectronicReceipt
      .includes(letter: [:patient, :author, :letterhead])
      .unread
      .for_recipient(current_user.id)
      .order(created_at: :asc)
    CollectionPresenter.new(receipts, Letters::ElectronicReceiptPresenter)
  end
end