From b405e0a5dd4b658780837a4104675b2c9713cb17 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Fri, 14 Jan 2011 12:17:12 +0100 Subject: [PATCH] fix query utils propagation when used in other modules (validations, "inherited" query utils, ...) --- lib/report/query_utils.rb | 11 +++++++++++ lib/report/validation.rb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/report/query_utils.rb b/lib/report/query_utils.rb index 3408aff20d..a4952ab216 100644 --- a/lib/report/query_utils.rb +++ b/lib/report/query_utils.rb @@ -4,6 +4,17 @@ module Report::QueryUtils delegate :quoted_false, :quoted_true, :to => "ActiveRecord::Base.connection" attr_writer :engine + module PropagationHook + def append_features(base) + ancestors[1..-1].reverse_each { |m| base.send(:include, m) } + base.extend PropagationHook + base.extend self + super + end + end + + extend PropagationHook + ## # Subclass of Report to be used for constant lookup and such. # It is considered public API to override this method i.e. in Tests. diff --git a/lib/report/validation.rb b/lib/report/validation.rb index 2993cb5fe1..7fa890b268 100644 --- a/lib/report/validation.rb +++ b/lib/report/validation.rb @@ -14,7 +14,7 @@ module Report::Validation def register_validation(val_method) const_name = val_method.to_s.camelize begin - val_module = Report::Validation.const_get const_name + val_module = engine::Validation.const_get const_name singleton_class.send(:include, val_module) val_method = "validate_" + val_method.to_s.pluralize if method(val_method)