ref: master
plugins/anti_spam/lib/anti_spam_plugin/wrapper.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
class AntiSpamPlugin::Wrapper < SimpleDelegator include Rakismet::Model @@wrappers = [] cattr_accessor :wrappers def self.wrap(object) wrapper = wrappers.find { |wrapper| wrapper.wraps?(object) } wrapper ? wrapper.new(object) : object end def self.wraps?(object) false end def self.inherited(child) child.rakismet_attrs wrappers << child end end Dir.glob(File.join(AntiSpamPlugin.root_path, 'lib', 'anti_spam_plugin', '*_wrapper.rb')) do |file| load(file) end |