Class: Akismetor
Overview
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Class Method Summary collapse
-
.spam?(attributes) ⇒ Boolean
Does a comment-check on Akismet with the submitted hash.
-
.submit_ham(attributes) ⇒ Object
Does a submit-ham on Akismet with the submitted hash.
-
.submit_spam(attributes) ⇒ Object
Does a submit-spam on Akismet with the submitted hash.
Instance Method Summary collapse
- #execute(command) ⇒ Object
-
#initialize(attributes) ⇒ Akismetor
constructor
A new instance of Akismetor.
Constructor Details
#initialize(attributes) ⇒ Akismetor
Returns a new instance of Akismetor.
28 29 30 |
# File 'lib/aerial/vendor/akismetor.rb', line 28 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/aerial/vendor/akismetor.rb', line 7 def attributes @attributes end |
Class Method Details
.spam?(attributes) ⇒ Boolean
Does a comment-check on Akismet with the submitted hash. Returns true or false depending on response.
11 12 13 |
# File 'lib/aerial/vendor/akismetor.rb', line 11 def self.spam?(attributes) self.new(attributes).execute('comment-check') == "true" end |
.submit_ham(attributes) ⇒ Object
Does a submit-ham on Akismet with the submitted hash. Use this for a false positive, when Akismet incorrectly rejects a normal comment
23 24 25 |
# File 'lib/aerial/vendor/akismetor.rb', line 23 def self.submit_ham(attributes) self.new(attributes).execute('submit-ham') end |
.submit_spam(attributes) ⇒ Object
Does a submit-spam on Akismet with the submitted hash. Use this when Akismet incorrectly approves a spam comment.
17 18 19 |
# File 'lib/aerial/vendor/akismetor.rb', line 17 def self.submit_spam(attributes) self.new(attributes).execute('submit-spam') end |
Instance Method Details
#execute(command) ⇒ Object
32 33 34 35 36 |
# File 'lib/aerial/vendor/akismetor.rb', line 32 def execute(command) http = Net::HTTP.new("#{attributes[:key]}.rest.akismet.com", 80) response, content = http.post("/1.1/#{command}", attributes_for_post, http_headers) content end |