From 93c1f11c0a5097a5431819a1551a02a869a16a38 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Wed, 28 Dec 2011 15:38:16 +0000 Subject: Support configuration on ActiveRecord::Model. The problem: We need to be able to specify configuration in a way that can be inherited to models that include ActiveRecord::Model. So it is no longer sufficient to put 'top level' config on ActiveRecord::Base, but we do want configuration specified on ActiveRecord::Base and descendants to continue to work. So we need something like class_attribute that can be defined on a module but that is inherited when ActiveRecord::Model is included. The solution: added ActiveModel::Configuration module which provides a config_attribute macro. It's a bit specific hence I am not putting this in Active Support or making it a 'public API' at present. --- .../test/cases/attribute_methods/read_test.rb | 1 - activerecord/test/cases/configuration_test.rb | 26 ---------------------- 2 files changed, 27 deletions(-) delete mode 100644 activerecord/test/cases/configuration_test.rb (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/attribute_methods/read_test.rb b/activerecord/test/cases/attribute_methods/read_test.rb index 375c207d20..0df9ffc0c5 100644 --- a/activerecord/test/cases/attribute_methods/read_test.rb +++ b/activerecord/test/cases/attribute_methods/read_test.rb @@ -18,7 +18,6 @@ module ActiveRecord def self.active_record_super; Base; end def self.base_class; self; end - include ActiveRecord::Configuration include ActiveRecord::AttributeMethods def self.column_names diff --git a/activerecord/test/cases/configuration_test.rb b/activerecord/test/cases/configuration_test.rb deleted file mode 100644 index 872f1fc33b..0000000000 --- a/activerecord/test/cases/configuration_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'cases/helper' - -class ConfigurationTest < ActiveRecord::TestCase - def test_configuration - @klass = Class.new do - include ActiveRecord::Configuration - end - - ActiveRecord::Configuration.define :omg - - ActiveRecord::Configuration.omg = "omg" - - assert_equal "omg", @klass.new.omg - assert !@klass.new.respond_to?(:omg=) - assert_equal "omg", @klass.omg - - @klass.omg = "wtf" - - assert_equal "wtf", @klass.omg - assert_equal "wtf", @klass.new.omg - ensure - ActiveRecord::Configuration.send(:undef_method, :omg) - ActiveRecord::Configuration::ClassMethods.send(:undef_method, :omg) - ActiveRecord::Configuration::ClassMethods.send(:undef_method, :omg=) - end -end -- cgit v1.2.3