Class: HideAncestry::ModelManage::CustomAncestryUpdater

Inherits:
Base
  • Object
show all
Defined in:
lib/hide_ancestry/model_manage/custom_ancestry_updater.rb

Instance Attribute Summary

Attributes inherited from Base

#instance

Instance Method Summary collapse

Methods inherited from Base

call, #initialize

Constructor Details

This class inherits a constructor from HideAncestry::ModelManage::Base

Instance Method Details

#callObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/hide_ancestry/model_manage/custom_ancestry_updater.rb', line 4

def call
  # If descendant of hidden node will change its parent
  clean_instance_from_hidden_parent if instance.hidden_parent_changed?
  change_hide_ancestry_col(instance) unless instance.hidden?

  # First, general iteration; useful when node updated
  instance.children.each { |child| update_each_child(child, instance) }

  # Fix nodes with #hidden? and its descendant nodes
  instance.hidden_children.each do |hidden_children|
    update_hidden_with_descendants(hidden_children, instance)
  end
end