Class: Defender::Test::Comment
- Inherits:
-
Object
- Object
- Defender::Test::Comment
- Extended by:
- ActiveModel::Callbacks, ActiveModel::Naming
- Includes:
- Spammable
- Defined in:
- lib/defender/test/comment.rb
Overview
A fake Comment class to use. No need to require ActiveRecord and set up an actual database. We will use ActiveModel for callbacks though.
Constant Summary
Constants included from Spammable
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#author_ip ⇒ Object
Returns the value of attribute author_ip.
-
#body ⇒ Object
Returns the value of attribute body.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#defensio_sig ⇒ Object
Returns the value of attribute defensio_sig.
-
#spam ⇒ Object
Returns the value of attribute spam.
Instance Method Summary collapse
-
#new_record? ⇒ Boolean
Returns true if save has been called, false otherwise.
-
#save(with_callbacks = true) ⇒ Object
Run save callback and make new_record? return false.
- #update_attribute(name, value) ⇒ Object
Methods included from Spammable
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
17 18 19 |
# File 'lib/defender/test/comment.rb', line 17 def end |
#author_ip ⇒ Object
Returns the value of attribute author_ip.
17 18 19 |
# File 'lib/defender/test/comment.rb', line 17 def end |
#body ⇒ Object
Returns the value of attribute body.
17 18 19 |
# File 'lib/defender/test/comment.rb', line 17 def body @body end |
#created_at ⇒ Object
Returns the value of attribute created_at.
17 18 19 |
# File 'lib/defender/test/comment.rb', line 17 def created_at @created_at end |
#defensio_sig ⇒ Object
Returns the value of attribute defensio_sig.
17 18 19 |
# File 'lib/defender/test/comment.rb', line 17 def defensio_sig @defensio_sig end |
#spam ⇒ Object
Returns the value of attribute spam.
17 18 19 |
# File 'lib/defender/test/comment.rb', line 17 def spam @spam end |
Instance Method Details
#new_record? ⇒ Boolean
Returns true if save has been called, false otherwise.
20 21 22 |
# File 'lib/defender/test/comment.rb', line 20 def new_record? !(@saved ||= false) end |
#save(with_callbacks = true) ⇒ Object
Run save callback and make new_record? return false.
The with_callbacks method is only for using this as a test interface.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/defender/test/comment.rb', line 27 def save(with_callbacks=true) if with_callbacks _run_save_callbacks do # We're not actually saving anything, just letting Defender know we # would be. unless defined?(@saved) && @saved _run_create_callbacks do @saved = true end end end else @saved = true end end |
#update_attribute(name, value) ⇒ Object
43 44 45 46 |
# File 'lib/defender/test/comment.rb', line 43 def update_attribute(name, value) self.send("#{name}=".to_sym, value) self.save end |