8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aa9229f commit 122dd5fCopy full SHA for 122dd5f
lib/coderay/helpers/plugin_host.rb
@@ -47,11 +47,21 @@ def load_all
47
# Example:
48
# yaml_plugin = MyPluginHost[:yaml]
49
def [] id, *args, &blk
50
- plugin = validate_id(id)
51
- begin
52
- plugin = plugin_hash.[](plugin, *args, &blk)
53
- end while plugin.is_a? String
54
- plugin
+ if !args.empty? || blk
+ plugin = validate_id(id)
+ begin
+ plugin = plugin_hash.[](plugin, *args, &blk)
+ end while plugin.is_a? String
55
+ plugin
56
+ else
57
+ (@cache ||= Hash.new do |cache, key|
58
+ plugin = validate_id(key)
59
60
+ plugin = plugin_hash.[](plugin)
61
62
+ cache[key] = plugin
63
+ end)[id]
64
+ end
65
end
66
67
alias load []
0 commit comments