Module: StewEucen::Acts::FertileForest::Table::Calculators

Defined in:
lib/fertile_forest/modules/calculators.rb

Overview

This module is for extending into derived class by ActiveRecord.
The caption contains “Instance Methods”, but it means “Class Methods” of each derived class.

Since:

  • File available since Release 1.0.0

Instance Method Summary collapse

Instance Method Details

#fill_required_columns_to_append!(node) ⇒ Object

Since:

  • File available since Release 1.0.0



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fertile_forest/modules/calculators.rb', line 26

def fill_required_columns_to_append!(node)
  # calculate depth and queue for appending.
  # If no interval, try to scoot over queue.
  if node.ff_base_id.to_i <= 0
    fill_info = ff_calc_required_columns_for_appending_as_root(node)
  else
    fill_info = ff_calc_required_columns_for_appending_as_internal(node)
  end

  # When fail to calc, can not save.
  # no need to set error message here.
  return false if fill_info.blank?

  # not need to set ff_grove, because posted node has it already.
  node.ff_queue = fill_info[:ff_queue]
  node.ff_depth = fill_info[:ff_depth]

  true
end