Skip to content

Commit cb5fa3f

Browse files
committed
Creating ApplicationModel methods.
These methods will be used by the ApplicationModel to send the correct configuration.
1 parent 5225628 commit cb5fa3f

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

activerecord/lib/active_record.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
module ActiveRecord
3232
extend ActiveSupport::Autoload
3333

34+
autoload :ApplicationConfiguration
3435
autoload :Base
3536
autoload :Callbacks
3637
autoload :Core
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module ActiveRecord
2+
module ApplicationConfiguration
3+
extend ActiveSupport::Concern
4+
5+
module ClassMethods
6+
def configs_from(application)
7+
app_model = self
8+
9+
application.singleton_class.instance_eval do
10+
define_method(:application_model) { app_model }
11+
end
12+
13+
define_singleton_method(:configs_from_application) { application }
14+
end
15+
end
16+
end
17+
end

activerecord/lib/active_record/base.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ class Base
293293
extend Explain
294294
extend Delegation::DelegateCache
295295

296+
include ApplicationConfiguration
296297
include Persistence
297298
include ReadonlyAttributes
298299
include ModelSchema
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
class ApplicationModel < ActiveRecord::Base
22
self.abstract_class = true
3+
configs_from Rails.application
34
end

railties/test/application/rake_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_should_not_eager_load_model_for_rake
9999
end
100100

101101
def test_code_statistics_sanity
102-
assert_match "Code LOC: 8 Test LOC: 0 Code to Test Ratio: 1:0.0",
102+
assert_match "Code LOC: 9 Test LOC: 0 Code to Test Ratio: 1:0.0",
103103
Dir.chdir(app_path){ `rake stats` }
104104
end
105105

0 commit comments

Comments
 (0)