Class: Journal

Inherits:
ApplicationRecord show all
Defined in:
app/models/journal.rb

Overview

Model to represent patient journals

Instance Method Summary collapse

Methods inherited from ApplicationRecord

#==

Instance Method Details

#list_entries(limit: 4) ⇒ Object


17
18
19
20
# File 'app/models/journal.rb', line 17

def list_entries(limit: 4)
  entries = journal_entries.order('entry_date DESC').limit(limit)
  entries.join(' ')
end

#read_entry(day: Date.today) ⇒ Object


22
23
24
# File 'app/models/journal.rb', line 22

def read_entry(day: Date.today)
  JournalEntry.where(entry_date: day.beginning_of_day..day.end_of_day)
end

#read_last(last_n: 1) ⇒ Object


26
27
28
# File 'app/models/journal.rb', line 26

def read_last(last_n: 1)
  JournalEntry.order('ID DESC').limit(last_n)
end

#to_sObject


30
31
32
# File 'app/models/journal.rb', line 30

def to_s
  name
end