rails_2_preload 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rails_2_preload.rb +2 -26
- metadata +2 -2
data/lib/rails_2_preload.rb
CHANGED
@@ -69,32 +69,8 @@ module Rails2Preload
|
|
69
69
|
@preload_methods, @postload_methods = METHODS[0..index - 1], METHODS[index..-1]
|
70
70
|
end
|
71
71
|
|
72
|
-
# By default, we'll preload
|
73
|
-
|
74
|
-
self.preload_until(:load_application_classes)
|
75
|
-
|
76
|
-
# Called from .spin.rb to add all hooks necessary to integrate
|
77
|
-
# Rails2Preload.
|
78
|
-
def self.add_spin_hooks
|
79
|
-
Spin.hook(:before_preload) { Rails2Preload.prepare_rails }
|
80
|
-
|
81
|
-
Spin.hook(:after_preload) do
|
82
|
-
if Rails2Preload.preload_methods.include? :load_application_classes
|
83
|
-
# If classes are preloaded, empty the connection pool so forked
|
84
|
-
# processes are forced to establish new connections. Otherwise, the
|
85
|
-
# second time a test is run, an exception like this is raised:
|
86
|
-
# ActiveRecord::StatementInvalid PGError: no connection to the server
|
87
|
-
ActiveRecord::Base.connection_pool.disconnect!
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
Spin.hook(:after_fork) do
|
92
|
-
# Create a new initializer instance, but reuse the configuration already
|
93
|
-
# established by the preload phase.
|
94
|
-
initializer = Rails::Initializer.new(Rails.configuration)
|
95
|
-
initializer.postload
|
96
|
-
end
|
97
|
-
end
|
72
|
+
# By default, outside the context of Spin, we'll preload everything.
|
73
|
+
self.preload_until(:disable_dependency_loading)
|
98
74
|
|
99
75
|
# Called by the Rails patch to run the preload phase.
|
100
76
|
def self.preload(initializer)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_2_preload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! "The purpose of Rails2Preload is to optimize testing with Spin\n and
|
15
15
|
Rails 2. It does this by splitting the Rails 2 initialization method\n (Rails::Initializer#process)
|