Module: ActiveArchive::Methods
- Defined in:
- lib/active_archive/methods.rb
Instance Method Summary collapse
- #archivable? ⇒ Boolean
- #archive_all(conditions = nil) ⇒ Object
- #archive_all!(conditions = nil) ⇒ Object (also: #destroy_all!)
- #unarchive_all(conditions = nil) ⇒ Object (also: #undestroy_all)
Instance Method Details
#archivable? ⇒ Boolean
6 7 8 |
# File 'lib/active_archive/methods.rb', line 6 def archivable? columns.detect { |col| col.name == 'archived_at' } end |
#archive_all(conditions = nil) ⇒ Object
10 11 12 |
# File 'lib/active_archive/methods.rb', line 10 def archive_all(conditions = nil) (conditions ? where(conditions) : all).to_a.each(&:archive) end |
#archive_all!(conditions = nil) ⇒ Object Also known as: destroy_all!
14 15 16 |
# File 'lib/active_archive/methods.rb', line 14 def archive_all!(conditions = nil) (conditions ? where(conditions) : all).to_a.each { |r| r.send(:archive, :force) } end |
#unarchive_all(conditions = nil) ⇒ Object Also known as: undestroy_all
20 21 22 |
# File 'lib/active_archive/methods.rb', line 20 def unarchive_all(conditions = nil) (conditions ? where(conditions) : all).to_a.each(&:unarchive) end |