demarches-normaliennes/app/models/sorted_column.rb

23 lines
411 B
Ruby
Raw Normal View History

2024-09-23 10:35:00 +02:00
# frozen_string_literal: true
class SortedColumn
2024-09-26 17:18:43 +02:00
attr_reader :column, :order
2024-09-23 10:35:00 +02:00
def initialize(column:, order:)
@column = column
@order = order
end
def ascending? = @order == 'asc'
def opposite_order = ascending? ? 'desc' : 'asc'
2024-09-23 10:35:00 +02:00
def ==(other)
other&.column == column && other.order == order
end
def sort_by_notifications?
@column.notifications? && @order == 'desc'
end
2024-09-23 10:35:00 +02:00
end