Module: PaperTrail::Model::InstanceMethods

Defined in:
lib/paper_trail/has_paper_trail.rb

Overview

Wrap the following methods in a module so we can include them only in the ActiveRecord models that declare has_paper_trail.

Instance Method Summary collapse

Instance Method Details

#appear_as_new_record(&block) ⇒ Object

Deprecated.


197
198
199
200
# File 'lib/paper_trail/has_paper_trail.rb', line 197

def appear_as_new_record(&block)
  self.class.paper_trail_deprecate "appear_as_new_record"
  paper_trail.appear_as_new_record(&block)
end

#attributes_before_changeObject

Deprecated.


324
325
326
327
# File 'lib/paper_trail/has_paper_trail.rb', line 324

def attributes_before_change
  self.class.paper_trail_deprecate "attributes_before_change"
  paper_trail.attributes_before_change
end

#changed_and_not_ignoredObject

Deprecated.


354
355
356
357
# File 'lib/paper_trail/has_paper_trail.rb', line 354

def changed_and_not_ignored
  self.class.paper_trail_deprecate "changed_and_not_ignored"
  paper_trail.changed_and_not_ignored
end

#changed_notably?Boolean

Deprecated.

Returns:

  • (Boolean)


336
337
338
339
# File 'lib/paper_trail/has_paper_trail.rb', line 336

def changed_notably?
  self.class.paper_trail_deprecate "changed_notably?"
  paper_trail.changed_notably?
end

#changes_for_paper_trailObject

Deprecated.


263
264
265
266
# File 'lib/paper_trail/has_paper_trail.rb', line 263

def changes_for_paper_trail
  self.class.paper_trail_deprecate "changes", "changes_for_paper_trail"
  paper_trail.changes
end

#clear_rolled_back_versionsObject

Deprecated.


149
150
151
152
# File 'lib/paper_trail/has_paper_trail.rb', line 149

def clear_rolled_back_versions
  self.class.paper_trail_deprecate "clear_rolled_back_versions"
  paper_trail.clear_rolled_back_versions
end

#clear_version_instance!Object

Deprecated.

See deprecation comment for record_create



270
271
272
# File 'lib/paper_trail/has_paper_trail.rb', line 270

def clear_version_instance!
  paper_trail.clear_version_instance
end

#ignored_attr_has_changed?Boolean

Deprecated.

Returns:

  • (Boolean)


342
343
344
345
# File 'lib/paper_trail/has_paper_trail.rb', line 342

def ignored_attr_has_changed?
  self.class.paper_trail_deprecate "ignored_attr_has_changed?"
  paper_trail.ignored_attr_has_changed?
end

#live?Boolean

Deprecated.

Returns:

  • (Boolean)


131
132
133
134
# File 'lib/paper_trail/has_paper_trail.rb', line 131

def live?
  self.class.paper_trail_deprecate "live?"
  paper_trail.live?
end

#merge_metadata(data) ⇒ Object

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.

Deprecated.


318
319
320
321
# File 'lib/paper_trail/has_paper_trail.rb', line 318

def (data)
  self.class.paper_trail_deprecate "merge_metadata"
  paper_trail.(data)
end

#next_versionObject

Deprecated.


179
180
181
182
# File 'lib/paper_trail/has_paper_trail.rb', line 179

def next_version
  self.class.paper_trail_deprecate "next_version"
  paper_trail.next_version
end

#notably_changedObject

Deprecated.


348
349
350
351
# File 'lib/paper_trail/has_paper_trail.rb', line 348

def notably_changed
  self.class.paper_trail_deprecate "notably_changed"
  paper_trail.notably_changed
end

#object_attrs_for_paper_trailObject

Deprecated.


330
331
332
333
# File 'lib/paper_trail/has_paper_trail.rb', line 330

def object_attrs_for_paper_trail
  self.class.paper_trail_deprecate "object_attrs_for_paper_trail"
  paper_trail.object_attrs_for_paper_trail
end

#originatorObject

Deprecated.


143
144
145
146
# File 'lib/paper_trail/has_paper_trail.rb', line 143

def originator
  self.class.paper_trail_deprecate "originator"
  paper_trail.originator
end

#paper_trailObject



126
127
128
# File 'lib/paper_trail/has_paper_trail.rb', line 126

def paper_trail
  ::PaperTrail::RecordTrail.new(self)
end

#paper_trail_enabled_for_model?Boolean

Deprecated.

Returns:

  • (Boolean)


185
186
187
188
# File 'lib/paper_trail/has_paper_trail.rb', line 185

def paper_trail_enabled_for_model?
  self.class.paper_trail_deprecate "enabled_for_model?", "paper_trail_enabled_for_model?"
  paper_trail.enabled_for_model?
end

#paper_trail_originatorObject

Deprecated.


137
138
139
140
# File 'lib/paper_trail/has_paper_trail.rb', line 137

def paper_trail_originator
  self.class.paper_trail_deprecate "originator", "paper_trail_originator"
  paper_trail.originator
end

#paper_trail_switched_on?Boolean

Deprecated.

The new method is named “enabled?” for consistency.

Returns:

  • (Boolean)


361
362
363
364
# File 'lib/paper_trail/has_paper_trail.rb', line 361

def paper_trail_switched_on?
  self.class.paper_trail_deprecate "enabled?", "paper_trail_switched_on?"
  paper_trail.enabled?
end

#previous_versionObject

Deprecated.


173
174
175
176
# File 'lib/paper_trail/has_paper_trail.rb', line 173

def previous_version
  self.class.paper_trail_deprecate "previous_version"
  paper_trail.previous_version
end

#pt_record_object_changes?Boolean

Deprecated.

Returns:

  • (Boolean)


245
246
247
248
# File 'lib/paper_trail/has_paper_trail.rb', line 245

def pt_record_object_changes?
  self.class.paper_trail_deprecate "record_object_changes?", "pt_record_object_changes?"
  paper_trail.record_object_changes?
end

#pt_recordable_objectObject

Deprecated.


251
252
253
254
# File 'lib/paper_trail/has_paper_trail.rb', line 251

def pt_recordable_object
  self.class.paper_trail_deprecate "recordable_object", "pt_recordable_object"
  paper_trail.recordable_object
end

#pt_recordable_object_changesObject

Deprecated.


257
258
259
260
# File 'lib/paper_trail/has_paper_trail.rb', line 257

def pt_recordable_object_changes
  self.class.paper_trail_deprecate "recordable_object_changes", "pt_recordable_object_changes"
  paper_trail.recordable_object_changes
end

#record_createObject

Deprecated.

record_create is deprecated in favor of paper_trail.record_create, but does not yet print a deprecation warning. When the after_create callback is registered (by ModelConfig#on_create) we still refer to this method by name, e.g.

@model_class.after_create :record_create, if: :save_version?

instead of using the preferred method paper_trail.record_create, e.g.

@model_class.after_create { |r| r.paper_trail.record_create if r.save_version?}

We still register the callback by name so that, if someone calls has_paper_trail twice, the callback will not be registered twice. Our own test suite calls has_paper_trail many times for the same class.

In the future, perhaps we should require that users only set up PT once per class.



234
235
236
# File 'lib/paper_trail/has_paper_trail.rb', line 234

def record_create
  paper_trail.record_create
end

#record_destroyObject

Deprecated.

See deprecation comment for record_create



282
283
284
# File 'lib/paper_trail/has_paper_trail.rb', line 282

def record_destroy
  paper_trail.record_destroy
end

#record_update(force = nil) ⇒ Object

Deprecated.

See deprecation comment for record_create



240
241
242
# File 'lib/paper_trail/has_paper_trail.rb', line 240

def record_update(force = nil)
  paper_trail.record_update(force)
end

#reset_timestamp_attrs_for_update_if_needed!Object

Deprecated.

See deprecation comment for record_create



276
277
278
# File 'lib/paper_trail/has_paper_trail.rb', line 276

def reset_timestamp_attrs_for_update_if_needed!
  paper_trail.reset_timestamp_attrs_for_update_if_needed
end

#reset_transaction_idObject

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.

Deprecated.


309
310
311
312
313
314
# File 'lib/paper_trail/has_paper_trail.rb', line 309

def reset_transaction_id
  ::ActiveSupport::Deprecation.warn(
    "reset_transaction_id is deprecated, use PaperTrail.clear_transaction_id"
  )
  PaperTrail.clear_transaction_id
end

#save_associations(version) ⇒ Object

Deprecated.


287
288
289
290
# File 'lib/paper_trail/has_paper_trail.rb', line 287

def save_associations(version)
  self.class.paper_trail_deprecate "save_associations"
  paper_trail.save_associations(version)
end

#save_associations_belongs_to(version) ⇒ Object

Deprecated.


293
294
295
296
# File 'lib/paper_trail/has_paper_trail.rb', line 293

def save_associations_belongs_to(version)
  self.class.paper_trail_deprecate "save_associations_belongs_to"
  paper_trail.save_associations_belongs_to(version)
end

#save_associations_has_and_belongs_to_many(version) ⇒ Object

Deprecated.


299
300
301
302
303
304
305
# File 'lib/paper_trail/has_paper_trail.rb', line 299

def save_associations_has_and_belongs_to_many(version)
  self.class.paper_trail_deprecate(
    "save_associations_habtm",
    "save_associations_has_and_belongs_to_many"
  )
  paper_trail.save_associations_habtm(version)
end

#save_version?Boolean

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.

Deprecated.

Returns:

  • (Boolean)


368
369
370
371
# File 'lib/paper_trail/has_paper_trail.rb', line 368

def save_version?
  self.class.paper_trail_deprecate "save_version?"
  paper_trail.save_version?
end

#source_versionObject

Deprecated.


155
156
157
158
# File 'lib/paper_trail/has_paper_trail.rb', line 155

def source_version
  self.class.paper_trail_deprecate "source_version"
  paper_trail.source_version
end

#touch_with_version(name = nil) ⇒ Object

Deprecated.


209
210
211
212
# File 'lib/paper_trail/has_paper_trail.rb', line 209

def touch_with_version(name = nil)
  self.class.paper_trail_deprecate "touch_with_version"
  paper_trail.touch_with_version(name)
end

#version_at(*args) ⇒ Object

Deprecated.


161
162
163
164
# File 'lib/paper_trail/has_paper_trail.rb', line 161

def version_at(*args)
  self.class.paper_trail_deprecate "version_at"
  paper_trail.version_at(*args)
end

#versions_between(start_time, end_time, _reify_options = {}) ⇒ Object

Deprecated.


167
168
169
170
# File 'lib/paper_trail/has_paper_trail.rb', line 167

def versions_between(start_time, end_time, _reify_options = {})
  self.class.paper_trail_deprecate "versions_between"
  paper_trail.versions_between(start_time, end_time)
end

#whodunnit(value, &block) ⇒ Object

Deprecated.


203
204
205
206
# File 'lib/paper_trail/has_paper_trail.rb', line 203

def whodunnit(value, &block)
  self.class.paper_trail_deprecate "whodunnit"
  paper_trail.whodunnit(value, &block)
end

#without_versioning(method = nil, &block) ⇒ Object

Deprecated.


191
192
193
194
# File 'lib/paper_trail/has_paper_trail.rb', line 191

def without_versioning(method = nil, &block)
  self.class.paper_trail_deprecate "without_versioning"
  paper_trail.without_versioning(method, &block)
end