From 932720c482a0c78b655b92ac644180c776fb37b5 Mon Sep 17 00:00:00 2001 From: jwollert Date: Wed, 11 May 2011 15:18:58 +0200 Subject: [PATCH] DRY code. always a pleasure to see it in the wild --- lib/report/chainable.rb | 4 ++++ lib/report/filter/base.rb | 4 ---- lib/report/group_by/base.rb | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/report/chainable.rb b/lib/report/chainable.rb index 38476e357a..2e2638758b 100644 --- a/lib/report/chainable.rb +++ b/lib/report/chainable.rb @@ -78,6 +78,10 @@ class Report < ActiveRecord::Base engine.chain_initializer.push block end + def self.cache_key + @cache_key ||= underscore_name + end + inherited_attribute :label, :default => :translation_needed inherited_attribute :properties, :list => true diff --git a/lib/report/filter/base.rb b/lib/report/filter/base.rb index f944f7617d..d148c9dec4 100644 --- a/lib/report/filter/base.rb +++ b/lib/report/filter/base.rb @@ -16,10 +16,6 @@ class Report::Filter attr_accessor :values - def self.cache_key - @cache_key ||= underscore_name - end - def cache_key self.class.cache_key + operator.to_s + Array(values).join(',') end diff --git a/lib/report/group_by/base.rb b/lib/report/group_by/base.rb index c0262587cb..6471cdcefd 100644 --- a/lib/report/group_by/base.rb +++ b/lib/report/group_by/base.rb @@ -16,10 +16,6 @@ class Report::GroupBy child.filter? end - def self.cache_key - @cache_key ||= underscore_name - end - def cache_key self.class.cache_key + type.to_s[0,1] end