module HierarchyWithLevel

Public Instance Methods

hchildren(result_set) click to toggle source
# File lib/hierarchy/hierarchy_with_level.rb, line 16
def hchildren(result_set)
  result_group = group_result_set(result_set)
  self.hchildren_structure(result_set,result_group)
end
hchildren_ids(result_set) click to toggle source
# File lib/hierarchy/hierarchy_with_level.rb, line 21
def hchildren_ids(result_set)
  result_group = group_result_set(result_set)
  self.hchildren_structure_ids(result_set,result_group)
end
hchildren_structure(result_set,result_group) click to toggle source
# File lib/hierarchy/hierarchy_with_level.rb, line 26
def hchildren_structure(result_set,result_group)
    result_group[self.id] unless presence_check(result_group[self.id]) 
end
hchildren_structure_ids(result_set,result_group) click to toggle source
# File lib/hierarchy/hierarchy_with_level.rb, line 30
def hchildren_structure_ids(result_set,result_group)
    result_group[self.id].map(&:id) unless presence_check(result_group[self.id]) 
end
hierarchy_level(result_set,depth = 0) click to toggle source
# File lib/hierarchy/hierarchy_with_level.rb, line 3
def hierarchy_level(result_set,depth = 0)
  result_group = group_result_set(result_set)
  level_check(depth) ? self.tree_structure_level(result_set,result_group) : self.tree_structure_level_depth(result_set,result_group,depth.to_i)
end
tree_structure_level(result_set,result_group,increment = 1) click to toggle source
# File lib/hierarchy/hierarchy_with_level.rb, line 8
def tree_structure_level(result_set,result_group,increment = 1)
  presence_check(result_group[self.id]) ? self.attributes.merge({:level => increment}) : self.attributes.merge({:level => increment, :children => result_group[self.id].map{|x| x.tree_structure_level(result_set,result_group,increment + 1)}}) 
end
tree_structure_level_depth(result_set,result_group,depth,increment = 1) click to toggle source
# File lib/hierarchy/hierarchy_with_level.rb, line 12
def tree_structure_level_depth(result_set,result_group,depth,increment = 1)
  presence_check(result_group[self.id]) ? self.attributes.merge({:level => increment}) : self.attributes.merge({:level => increment, :children => result_group[self.id].map{|x| x.tree_structure_level_depth(result_set,result_group,depth,increment + 1)}}) unless compare(increment,depth)
end