lib/active_archive/methods.rb in active_archive-5.3.0 vs lib/active_archive/methods.rb in active_archive-6.0.0
- old
+ new
@@ -6,22 +6,20 @@
def archivable?
columns.detect { |col| col.name == 'archived_at' }
end
def archive_all(conditions = nil)
- (conditions ? where(conditions) : all).to_a.each(&:archive)
+ records(conditions, action: :archive)
end
- def archive_all!(conditions = nil)
- (conditions ? where(conditions) : all).to_a.each { |r| r.send(:archive, :force) }
+ def unarchive_all(conditions = nil)
+ records(conditions, action: :unarchive)
end
- alias_method :destroy_all!, :archive_all!
+ private
- def unarchive_all(conditions = nil)
- (conditions ? where(conditions) : all).to_a.each(&:unarchive)
+ def records(conditions = nil, action:)
+ where(conditions).find_each(&action)
end
-
- alias_method :undestroy_all, :unarchive_all
end
end