Sha256: 085bf6fe1225c4df1edd7a875f81fc088fb998d43492485e23c30c4061b99044

Contents?: true

Size: 600 Bytes

Versions: 3

Compression:

Stored size: 600 Bytes

Contents

# frozen_string_literal: true

module PaperTrailScrapbook
  class Versions
    include Concord.new(:object)

    def versions
      filtered(object.versions | related_content).sort_by(&:created_at)
    end

    def related_content
      unless object.respond_to?(:trailed_related_content)
        return []
      end

      object.trailed_related_content.compact.flat_map(&:versions)
    end

    def filtered(object_versions)
      unless object.respond_to?(:version_filter)
        return object_versions
      end

      object_versions.select { |v| object.version_filter(v) }
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paper_trail_scrapbook-0.1.21 lib/paper_trail_scrapbook/versions.rb
paper_trail_scrapbook-0.1.20 lib/paper_trail_scrapbook/versions.rb
paper_trail_scrapbook-0.1.19 lib/paper_trail_scrapbook/versions.rb