Class: CommandTower::Messaging::InboxItem

Inherits:
ApplicationRecord show all
Defined in:
app/models/command_tower/messaging/inbox_item.rb

Constant Summary collapse

STATUS_CREATED =
"created"
STATUS_VIEWED =
"viewed"
STATUS_ARCHIVED =
"archived"
STATUS_DELETED =
"deleted"

Instance Method Summary collapse

Methods inherited from ApplicationRecord

attribute_to_type_mapping

Instance Method Details

#archived?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/command_tower/messaging/inbox_item.rb', line 30

def archived?
  archived_at.present?
end

#deleted?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/models/command_tower/messaging/inbox_item.rb', line 34

def deleted?
  deleted_at.present?
end

#lifecycle_labelObject

Denormalized label helper — timestamps remain authoritative for filters.



43
44
45
46
47
48
49
# File 'app/models/command_tower/messaging/inbox_item.rb', line 43

def lifecycle_label
  return STATUS_DELETED if deleted?
  return STATUS_ARCHIVED if archived?
  return STATUS_VIEWED if viewed?

  STATUS_CREATED
end

#unread?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/command_tower/messaging/inbox_item.rb', line 38

def unread?
  !viewed? && !archived? && !deleted?
end

#viewed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/command_tower/messaging/inbox_item.rb', line 26

def viewed?
  viewed_at.present?
end