Class: RailsAdmin::Extensions::PaperTrail::VersionProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_admin/extensions/paper_trail/auditing_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, user_class = User) ⇒ VersionProxy

Returns a new instance of VersionProxy


5
6
7
8
# File 'lib/rails_admin/extensions/paper_trail/auditing_adapter.rb', line 5

def initialize(version, user_class = User)
  @version = version
  @user_class = user_class
end

Instance Method Details

#created_atObject


15
16
17
# File 'lib/rails_admin/extensions/paper_trail/auditing_adapter.rb', line 15

def created_at
  @version.created_at
end

#itemObject


27
28
29
# File 'lib/rails_admin/extensions/paper_trail/auditing_adapter.rb', line 27

def item
  @version.item_id
end

#messageObject


10
11
12
13
# File 'lib/rails_admin/extensions/paper_trail/auditing_adapter.rb', line 10

def message
  @message = @version.event
  @version.respond_to?(:changeset) && @version.changeset.present? ? @message + ' [' + @version.changeset.to_a.collect { |c| c[0] + ' = ' + c[1][1].to_s }.join(', ') + ']' : @message
end

#tableObject


19
20
21
# File 'lib/rails_admin/extensions/paper_trail/auditing_adapter.rb', line 19

def table
  @version.item_type
end

#usernameObject


23
24
25
# File 'lib/rails_admin/extensions/paper_trail/auditing_adapter.rb', line 23

def username
  @user_class.find(@version.whodunnit).try(:email) rescue nil || @version.whodunnit
end