From e758564d81e1d7d40f68b678aab4cb7f1b466125 Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Thu, 24 Feb 2011 16:05:12 +0100 Subject: [PATCH] use usage_reportings dependents methods --- lib/report/filter/base.rb | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/report/filter/base.rb b/lib/report/filter/base.rb index b45504274d..301a692321 100644 --- a/lib/report/filter/base.rb +++ b/lib/report/filter/base.rb @@ -28,12 +28,39 @@ class Report::Filter # Filter::Project.dependent --> Filter::Issue # This could result in a UI where, if the Prject-filter was selected, # the Issue-filter automatically shows up. - def self.dependent(dependent = nil) - @dependent_filter = dependent if dependent + def self.dependent(klass) + self.dependents << klass end - def self.has_dependent? - !!@dependent_filter + def self.has_dependents? + @dependents && !@dependents.empty? + end + + def self.dependents(*args) + @dependents ||= [] + @dependents += args + end + + def self.cached(*args) + @cached ||= {} + @cached[args] ||= send(*args) + end + + ## + # all_dependents computes the depentends of this filter and recursively the + # all_dependents of this class' dependents. + def self.all_dependents + self.cached(:compute_injected_dependents) + end + + def self.compute_all_dependents + if self.has_dependents? + self.dependents.inject(self.dependents) do |ary, dep| + ary + dep.injected_dependents + end.uniq + else + [] + end end def value=(val)