Commit aae9aa42fe4e2e2f4ff5c1a034b5a285abbf08b2

Authored by Rodrigo Souto
1 parent 28ff2c57

anti-spam-plugin-wrapper: ensure to load concrete wrappers

plugins/anti_spam/lib/anti_spam_plugin/wrapper.rb
1 1 class AntiSpamPlugin::Wrapper < SimpleDelegator
2 2 include Rakismet::Model
3 3  
4   - @@wrappers = [AntiSpamPlugin::CommentWrapper, AntiSpamPlugin::SuggestArticleWrapper]
  4 + @@wrappers = []
  5 + cattr_accessor :wrappers
5 6  
6 7 def self.wrap(object)
7   - wrapper = @@wrappers.find { |wrapper| wrapper.wraps?(object) }
  8 + wrapper = wrappers.find { |wrapper| wrapper.wraps?(object) }
8 9 wrapper ? wrapper.new(object) : object
9 10 end
10 11  
... ... @@ -12,9 +13,11 @@ class AntiSpamPlugin::Wrapper &lt; SimpleDelegator
12 13 false
13 14 end
14 15  
15   -# FIXME You can't take for granted that the wrappers will be loaded and, therefore,
16   -# included in the @@wrappers variable.
17   -# def self.inherited(child)
18   -# @@wrappers << child
19   -# end
  16 + def self.inherited(child)
  17 + wrappers << child
  18 + end
  19 +end
  20 +
  21 +Dir.glob(File.join(AntiSpamPlugin.root_path, 'lib', 'anti_spam_plugin', '*_wrapper.rb')) do |file|
  22 + load(file)
20 23 end
... ...