app/services/record_sort.rb
def update(sort_by:)
    option = if options.map(&:by).include?(sort_by)
               options.detect { |opt| opt.by == sort_by }
             else
               default_sort_option
             end

    @sort_by = option.by
    @order = option.order

    self
  end
# Update @sort_by and @order attributes. These are used to track which sorting option is currently active.
Update @sort_by and @order attributes. These are used to track which sorting option is currently active.
Update @sort_by and @order attributes . These are used to track which sorting option is currently active .
def update(sort_by:)
    option = if options.map(&:by).include?(sort_by)
               options.detect { |opt| opt.by == sort_by }
             else
               default_sort_option
             end
    @sort_by = option.by
    @order = option.order
    self
  end
def update ( sort_by : ) option = if options . map ( & :by ) . include? ( sort_by ) options . detect { | opt | opt . by == sort_by } else default_sort_option end @sort_by = option . by @order = option . order self end
Update @sort_by and @order attributes.
Update @sort_by and @order attributes .
sort_by