Class: Renalware::System::Message

Inherits:
ApplicationRecord show all
Extended by:
Enumerize
Defined in:
app/models/renalware/system/message.rb

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Return true if the message should be visible. A message is visible if display_from is in the past and display_until is nil or in the future

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
# File 'app/models/renalware/system/message.rb', line 26

def active?
  return false if display_from.nil?

  now = Time.zone.now
  self.display_until ||= far_future_date
  return true if display_from < now && display_until > now

  false
end