Class: Thredded::MessageboardDestroyer

Inherits:
Object
  • Object
show all
Defined in:
app/commands/thredded/messageboard_destroyer.rb

Instance Method Summary collapse

Constructor Details

#initialize(messageboard_name) ⇒ MessageboardDestroyer

Returns a new instance of MessageboardDestroyer.



4
5
6
7
8
9
# File 'app/commands/thredded/messageboard_destroyer.rb', line 4

def initialize(messageboard_name)
  @messageboard = Thredded::Messageboard.friendly.find(messageboard_name)
  @connection = ActiveRecord::Base.connection
rescue
  say "No messageboard with the name '#{messageboard_name}' found."
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
# File 'app/commands/thredded/messageboard_destroyer.rb', line 11

def run
  return unless messageboard

  ActiveRecord::Base.transaction do
    destroy_all_lower_dependencies
    destroy_all_posts
    destroy_all_topics
    destroy_messageboard_and_everything_else
  end
end