module HierarchyNoLevel

Public Instance Methods

hierarchy(result_set,depth = 0) click to toggle source
# File lib/hierarchy/hierarchy_no_level.rb, line 3
def hierarchy(result_set,depth = 0)
  result_group = group_result_set(result_set)
  level_check(depth) ? self.tree_structure(result_set,result_group) : self.tree_structure_depth(result_set,result_group,depth.to_i)
end
tree_structure(result_set,result_group) click to toggle source
# File lib/hierarchy/hierarchy_no_level.rb, line 8
def tree_structure(result_set,result_group)
  presence_check(result_group[self.id]) ? self.attributes : self.attributes.merge({:children => result_group[self.id].map{|x| x.tree_structure(result_set,result_group)}}) 
end
tree_structure_depth(result_set,result_group,depth,increment = 1) click to toggle source
# File lib/hierarchy/hierarchy_no_level.rb, line 12
def tree_structure_depth(result_set,result_group,depth,increment = 1)
  presence_check(result_group[self.id]) ? self.attributes : self.attributes.merge({:children => result_group[self.id].map{|x| x.tree_structure_depth(result_set,result_group,depth,increment + 1)}}) unless compare(increment,depth) 
end