Class: PaperTrailScrapbook::UserJournal Private

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/paper_trail_scrapbook/user_journal.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class UserJournal provides history for a user, optionally scoped by object class and/or date range

Author:

Instance Method Summary collapse

Constructor Details

#initialize(user, opts = {}) ⇒ UserJournal

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of UserJournal.



12
13
14
15
16
17
18
19
20
# File 'lib/paper_trail_scrapbook/user_journal.rb', line 12

def initialize(user, opts = {})
  @user     = user
  @user_id  = String(user.id)
  @options  = opts
  @starts   = options[:start] || Time.at(0).in_time_zone
  @ends     = options[:end] || Time.current.in_time_zone

  @versions = PaperTrail::Version.where(query_params)
end

Instance Method Details

#storyString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Retries textual historical analysis of versions

Returns:

  • (String)

    analyzed versions



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/paper_trail_scrapbook/user_journal.rb', line 26

def story
  s = versions.map do |v|
    JournalEntry.new(v).story
  end.compact

  s.reverse! if PaperTrailScrapbook.config.recent_first

  s.join("\n\n")

  "#{preface}#{s.presence || 'No history'}"
end