Sha256: ddc758904e64b5b530c003ab375c597775b60c8473fae8fc69603cba61727090
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
require 'active_model' ## # Stuff to test Defender. You probably shouldn't use this in your application, # but it is included as an example of the minimum needed for a valid setup. module Defender::Test ## # A fake Comment class to use. No need to require ActiveRecord and set up an # actual database. We will use ActiveModel for callbacks though. class Comment extend ActiveModel::Naming extend ActiveModel::Callbacks define_model_callbacks :save # We now have a "valid" model, let's bring in Defender. include Defender::Spammable attr_accessor :body, :author, :author_ip, :created_at, :spam, :defensio_sig ## # Returns true if save has been called, false otherwise. def new_record? !@saved ||= false end ## # Run save callback and make {Defender::Test::Comment.new_record?} return false. def save _run_save_callbacks do # We're not actually saving anything, just letting Defender know we # would be. @saved = true end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
defender-2.0.2 | lib/defender/test/comment.rb |
defender-2.0.1 | lib/defender/test/comment.rb |
defender-2.0.0 | lib/defender/test/comment.rb |
defender-2.0.0beta1 | lib/defender/test/comment.rb |