module TemporalScopes::HasTemporalScopes::InstanceMethods
The following instance methods are added to `ActiveRecord::Base` objects, which classes have been called `has_temporal_scopes` on.
Public Instance Methods
archive(params = {})
click to toggle source
Archives an object, that is, makes it a past object.
@param params [Hash] a hash of parameters. @option params :at [DateTime] (Time.zonw.now) when to archive the object, i.e. the time when the present object becomes a past object, i.e. expires.
@return [ActiveRecord::Base] the archived object.
@example Archiving an object now.
article.archive
@example Archiving an object with effect 4 hours ago.
article.archive at: 4.hours.ago
# File lib/temporal_scopes/has_temporal_scopes.rb, line 121 def archive(params = {}) unless self.valid_to archive_at = params[:at] || Time.zone.now update_attribute(:valid_to, archive_at) end return self end