Class: Hertz::Notification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/hertz/notification.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.couriersObject



16
17
18
# File 'app/models/hertz/notification.rb', line 16

def couriers
  @couriers ||= []
end

Instance Method Details

#delivered_with?(courier) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/models/hertz/notification.rb', line 43

def delivered_with?(courier)
  deliveries.where(courier: courier).exists?
end

#mark_as_readObject



35
36
37
# File 'app/models/hertz/notification.rb', line 35

def mark_as_read
  update read_at: Time.zone.now
end

#mark_as_unreadObject



39
40
41
# File 'app/models/hertz/notification.rb', line 39

def mark_as_unread
  update read_at: nil
end

#mark_delivered_with(courier) ⇒ Object



47
48
49
# File 'app/models/hertz/notification.rb', line 47

def mark_delivered_with(courier)
  deliveries.create(courier: courier)
end

#read?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/hertz/notification.rb', line 27

def read?
  read_at.present?
end

#unread?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/hertz/notification.rb', line 31

def unread?
  read_at.nil?
end