@@ -131,7 +131,7 @@ def register plugin, id
131
131
132
132
# A Hash of plugion_id => Plugin pairs.
133
133
def plugin_hash
134
- @plugin_hash ||= make_plugin_hash
134
+ @plugin_hash ||= ( @plugin_hash = make_plugin_hash ) . tap { load_plugin_map }
135
135
end
136
136
137
137
# Returns an array of all .rb files in the plugin path.
@@ -158,7 +158,6 @@ def all_plugins
158
158
# This is done automatically when plugin_path is called.
159
159
def load_plugin_map
160
160
mapfile = path_to '_map'
161
- @plugin_map_loaded = true
162
161
if File . exist? mapfile
163
162
require mapfile
164
163
true
@@ -171,22 +170,16 @@ def load_plugin_map
171
170
172
171
# Return a plugin hash that automatically loads plugins.
173
172
def make_plugin_hash
174
- @plugin_map_loaded ||= false
175
173
Hash . new do |h , plugin_id |
176
174
id = validate_id ( plugin_id )
177
175
path = path_to id
178
176
begin
179
177
require path
180
178
rescue LoadError => boom
181
- if @plugin_map_loaded
182
- if h . has_key? ( :default )
183
- h [ :default ]
184
- else
185
- raise PluginNotFound , '%p could not load plugin %p: %s' % [ self , id , boom ]
186
- end
179
+ if h . has_key? ( :default )
180
+ h [ :default ]
187
181
else
188
- load_plugin_map
189
- h [ plugin_id ]
182
+ raise PluginNotFound , '%p could not load plugin %p: %s' % [ self , id , boom ]
190
183
end
191
184
else
192
185
# Plugin should have registered by now
@@ -270,7 +263,6 @@ def plugin_host host = nil
270
263
end
271
264
272
265
def aliases
273
- plugin_host . load_plugin_map
274
266
plugin_host . plugin_hash . inject [ ] do |aliases , ( key , _ ) |
275
267
aliases << key if plugin_host [ key ] == self
276
268
aliases
0 commit comments