Class: Renalware::HD::Sessions::CloseStaleOpenSessions::CloseableSessionQuery

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/hd/sessions/close_stale_open_sessions.rb

Instance Method Summary collapse

Instance Method Details

#eachObject



15
16
17
18
19
20
21
22
23
24
# File 'app/models/renalware/hd/sessions/close_stale_open_sessions.rb', line 15

def each
  Session::Open
    .where("performed_on <= ?", performed_before)
    .where.not(signed_off_by: nil)
    .find_each do |session|
    # Note the bang in becomes! is crucial in copying the session attributes
    # and setting the sti column appropriately
    yield CloseableSession.new(session.becomes!(Session::Closed))
  end
end