From 3f749fa8cd88101a4699d270abd8c17da071b4a9 Mon Sep 17 00:00:00 2001 From: jwollert Date: Thu, 9 Jun 2011 14:27:25 +0200 Subject: [PATCH] delegate Chainable calls of #table_joins, #table_name, #field, #display?, #help_text and #underscore_name to class --- lib/report/chainable.rb | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/lib/report/chainable.rb b/lib/report/chainable.rb index 2e2638758b..18c5ee00b3 100644 --- a/lib/report/chainable.rb +++ b/lib/report/chainable.rb @@ -5,9 +5,11 @@ class Report < ActiveRecord::Base include Enumerable include Report::QueryUtils extend Report::InheritedAttribute + extend Forwardable # this attr. should point to a symbol useable for translations inherited_attribute :applies_for, :default => :label_cost_entry_attributes + def_delegators :'self.class', :table_joins, :table_name, :field, :display?, :help_text, :underscore_name def self.accepts_property(*list) engine.accepted_properties.push(*list.map(&:to_s)) @@ -213,10 +215,6 @@ class Report < ActiveRecord::Base engine::Result.new engine.reporting_connection.select_all(sql_statement.to_s), {}, type end - def table_joins - self.class.table_joins - end - def cached(*args) @cached ||= {} @cached[args] ||= send(*args) @@ -286,14 +284,6 @@ class Report < ActiveRecord::Base @table_name || last_table end - def display? - self.class.display? - end - - def table_name - self.class.table_name - end - def with_table(fields) fields.map do |f| place_field_name = self.class.put_sql_table_names[f] || self.class.put_sql_table_names[f].nil? @@ -301,10 +291,6 @@ class Report < ActiveRecord::Base end end - def field - self.class.field - end - def mapping self.class.method(:mapping).to_proc end @@ -320,10 +306,6 @@ class Report < ActiveRecord::Base @field_map[field] end - def help_text - self.class.help_text - end - ## # Sets a help text to be displayed for this kind of Chainable. def self.help_text=(sym)