Com o prefixo this.* é possível referenciar campos do documento em funções JavaScript:
class Invoice
include Mongoid::Document
field :invoice_date, :type => Date
field :days_for_payment, :type => Integer
scope :overdue, where("(Math.round(this.invoice_date.getTime() / 1000) + (this.days_for_payment * 24 * 3600)) < #{Time.now.to_i}")
endO tratamento de timestamp em JavaScript difere de Ruby, então é necessário arredondar e remover milissegundos.
Cuidado: $where executa JavaScript por documento e não usa índice. Para grandes volumes, prefira agregação com $add e $multiply em campos de data reais.