class Connoisseur::Comment
Attributes
Public Class Methods
Internal: Define a comment via a DSL.
service - A Connoisseur::Service
for issuing API requests.
Yields a Comment::Definition
for declaring the comment's attributes.
Returns a Connoisseur::Comment
.
# File lib/connoisseur/comment.rb, line 11 def self.define(service, &block) new service, parameters_for(&block) end
Internal: Initialize a Connoisseur::Comment
.
service - A Connoisseur::Service
for issuing API requests. parameters - A Hash of POST parameters describing the comment for use in API requests.
# File lib/connoisseur/comment.rb, line 28 def initialize(service, parameters) @service, @parameters = service, parameters end
Internal: Generate a comment's parameters via the Definition
DSL.
Yields a Comment::Definition
for declaring the comment's attributes.
Returns a Hash of parameters.
# File lib/connoisseur/comment.rb, line 20 def self.parameters_for(&block) Definition.build(&block).parameters end
Public Instance Methods
Public: Determine whether a comment is spam or ham.
Examples
result = comment.check result.spam? result.valid?
Returns a Connoisseur::Result
. Raises Connoisseur::Result::InvalidError
if the Akismet API responds unexpectedly.
# File lib/connoisseur/comment.rb, line 42 def check @service.check(@parameters) end
Public: Inform Akismet that the comment should have been marked ham.
Returns nothing.
# File lib/connoisseur/comment.rb, line 56 def ham! @service.ham!(@parameters) end
Public: Inform Akismet that the comment should have been marked spam.
Returns nothing.
# File lib/connoisseur/comment.rb, line 49 def spam! @service.spam!(@parameters) end
Public: Inform Akismet that it incorrectly classified the comment.
spam - A boolean indicating whether the comment should have been marked spam.
Returns nothing.
# File lib/connoisseur/comment.rb, line 65 def update!(spam:) if spam spam! else ham! end end