Module: Cthulhu

Defined in:
lib/Cthulhu.rb,
lib/cthulhu/scopper.rb,
lib/cthulhu/version.rb,
lib/cthulhu/destroyer.rb,
lib/cthulhu/uncrawlable_hierarchy.rb

Defined Under Namespace

Classes: Destroyer, Scopper, UncrawlableHierarchy

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.destroy!(active_record_object, blacklisted: [], not_to_be_crawled: [], overrides: {}) ⇒ Object

Removes the object and all of its children by crawling through defined associations.

  • active_record_object - the record to be destroyed.

  • :blacklisted - models not to be destroyed. i.e. views that you are

using through active record.

  • :not_to_be_crawled - Association that should not be traveled. e.g.

‘Post-Comment’ means crawling from Post to Comment model is forbidden.

  • :overrides - here you can override options of active record

associations. For example, you can set inverse_of or dependent: :nullify without actually changing the association.



20
21
22
23
24
25
# File 'lib/Cthulhu.rb', line 20

def self.destroy! active_record_object,
  blacklisted: [],
  not_to_be_crawled: [],
  overrides: {}
  Destroyer.new(active_record_object, blacklisted, not_to_be_crawled, overrides).destroy!
end