Class: DynamoRecord::TaskHelpers::Cleanup

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamo-record/task_helpers/cleanup.rb

Class Method Summary collapse

Class Method Details

.runObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/dynamo-record/task_helpers/cleanup.rb', line 4

def self.run
  raise 'Task not available on production' if Rails.env.production?
  Dir[Rails.root.join('app/models/*.rb').to_s].each do |filename|
    klass = File.basename(filename, '.rb').camelize.constantize
    if klass.included_modules.include? DynamoRecord::Model
      puts "Deleting all items in table: #{klass}"
      klass.scan.each(&:delete!)
    end
  end
end