Module: ActsAsDAG::ClassMethods

Defined in:
lib/acts_as_dag/acts_as_dag.rb

Instance Method Summary collapse

Instance Method Details

#acts_like_dag?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/acts_as_dag/acts_as_dag.rb', line 105

def acts_like_dag?
  true
end

#reset_hierarchy(categories_to_reset = self.all) ⇒ Object

Remove all hierarchy information for this category Can pass a list of categories to reset



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/acts_as_dag/acts_as_dag.rb', line 111

def reset_hierarchy(categories_to_reset = self.all)
  ids = categories_to_reset.collect(&:id)

  link_table_entries.where("parent_id IN (?) OR child_id IN (?)", ids, ids).delete_all

  descendant_table_entries.where("descendant_id IN (?) OR ancestor_id IN (?)", ids, ids).delete_all

  categories_to_reset.each do |category|
    category.send :initialize_dag
  end
end