23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/models/provider_group.rb', line 23
def self.tree(exclude=nil)
result = {}
inject = lambda{|result, exclude, entry, level|
unless entry == exclude
result["#{'--'*level}#{' ' if level > 0}#{entry.title}"] = entry.id
entry.provider_groups.each do |x|
inject.call(result, exclude, x, level+1)
end
end
}
ProviderGroup.where(:provider_group_id => nil).order(:title).
select{|x| x.provider_group.blank?}.each do |x|
inject.call(result, exclude, x, 0)
end
result
end
|