lib/paper_trail/cleaner.rb
def gather_versions(item_id = nil, date = :all)
      unless date == :all || date.respond_to?(:to_date)
        raise ArgumentError, "Expected date to be a Timestamp or :all"
      end
      versions = item_id ? PaperTrail::Version.where(item_id: item_id) : PaperTrail::Version
      versions = versions.order(PaperTrail::Version.timestamp_sort_order)
      versions = versions.between(date.to_date, date.to_date + 1.day) unless date == :all

      # If `versions` has not been converted to an ActiveRecord::Relation yet,
      # do so now.
      versions = PaperTrail::Version.all if versions == PaperTrail::Version
      versions.group_by(&:item_id)
    end
def gather_versions(item_id = nil, date = :all)
      unless date == :all || date.respond_to?(:to_date)
        raise ArgumentError, "Expected date to be a Timestamp or :all"
      end
      versions = item_id ? PaperTrail::Version.where(item_id: item_id) : PaperTrail::Version
      versions = versions.order(PaperTrail::Version.timestamp_sort_order)
      versions = versions.between(date.to_date, date.to_date + 1.day) unless date == :all

      # If `versions` has not been converted to an ActiveRecord::Relation yet,
      # do so now.
      versions = PaperTrail::Version.all if versions == PaperTrail::Version
      versions.group_by(&:item_id)
    end
Returns a hash of versions grouped by the `item_id` attribute formatted
 like this: {:item_id => PaperTrail::Version}. If `item_id` or `date` is
 set, versions will be narrowed to those pointing at items with those ids
 that were created on specified date. Versions are returned in
 chronological order.