lib/fertile_forest/modules/finders.rb
#
# Find grandparent node from base node.
#
# @param base_obj [Entity|int] Base node|id to find.
# @param columns [Array] Columns for SELECT clause.
# @return [Entity] Grandparent node.
# @return [nil] No grandparent node.
#
Find grandparent node from base node.
Find grandparent node from base node .
def grandparent(base_obj, columns = nil)
            base_node = ff_resolve_nodes(base_obj)
            return nil if base_node.blank?
            grand_number = 2
            grandparent_depth = base_node.ff_depth - grand_number
            return nil if grandparent_depth < ROOT_DEPTH
            trunk_query = trunk(base_node, grand_number, columns)
            return nil if trunk_query.blank?
            trunk_query.first
          end
def grandparent ( base_obj , columns = nil ) base_node = ff_resolve_nodes ( base_obj ) return nil if base_node . blank? grand_number = 2 grandparent_depth = base_node . ff_depth - grand_number return nil if grandparent_depth < ROOT_DEPTH trunk_query = trunk ( base_node , grand_number , columns ) return nil if trunk_query . blank? trunk_query . first end
Find grandparent node from base node.
Find grandparent node from base node .
None
Entity
No grandparent node.
No grandparent node .
nil
base_obj
Base node|id to find.
Base node|id to find .
columns
Columns for SELECT clause.
Columns for SELECT clause .