Class: PaperTrail::Version
- Inherits:
-
Object
- Object
- PaperTrail::Version
show all
- Includes:
- Mongoid::Autoinc, Mongoid::Document, VersionConcern
- Defined in:
- lib/mongo_trails/mongo_support/version.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#changeset, #index, #next, #object_deserialized, #paper_trail_originator, #previous, #reify, #sibling_versions, #terminator
Constructor Details
#initialize(data) ⇒ Version
Returns a new instance of Version.
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/mongo_trails/mongo_support/version.rb', line 41
def initialize(data)
item = data.delete(:item)
if item.present?
data[:item_type] = item.class.name
data[:item_id] = item.id
end
data[:created_at] = Time.zone&.now || Time.now
super
end
|
Class Method Details
.find(id) ⇒ Object
32
33
34
|
# File 'lib/mongo_trails/mongo_support/version.rb', line 32
def find(id)
find_by(integer_id: id)
end
|
.prefix_map ⇒ Object
36
37
38
|
# File 'lib/mongo_trails/mongo_support/version.rb', line 36
def prefix_map
(PaperTrail.config.mongo_prefix.is_a?(Proc) ? PaperTrail.config.mongo_prefix.call : 'paper_trail') || 'paper_trail'
end
|
.reset ⇒ Object
28
29
30
|
# File 'lib/mongo_trails/mongo_support/version.rb', line 28
def reset
Mongoid::QueryCache.clear_cache
end
|
Instance Method Details
#item ⇒ Object
52
53
54
|
# File 'lib/mongo_trails/mongo_support/version.rb', line 52
def item
item_type.constantize.find(item_id)
end
|