Class: ActiveGit::DbDeleteAll

Inherits:
Object
  • Object
show all
Defined in:
lib/active_git/events/db_delete_all.rb

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ DbDeleteAll

Returns a new instance of DbDeleteAll.



4
5
6
# File 'lib/active_git/events/db_delete_all.rb', line 4

def initialize(model)
  @model = model
end

Instance Method Details

#synchronize(synchronizer) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/active_git/events/db_delete_all.rb', line 8

def synchronize(synchronizer)
  synchronizer.define_job do
    ActiveGit.configuration.logger.debug "[ActiveGit] Deleting all #{@model.model_name} models"
    @model.delete_all

    @model.git_included_models.each do |nested_model|
      ActiveGit.configuration.logger.debug "[ActiveGit] Deleting all #{nested_model.model_name} models (nested of #{@model.model_name})"
      nested_model.delete_all
    end
  end
end