lib/defender/document.rb in defender-1.0.1 vs lib/defender/document.rb in defender-1.0.2
- old
+ new
@@ -32,10 +32,18 @@
#
# @return [String]
attr_reader :signature
##
+ # A float denoting how spammy a document is.
+ #
+ # This could be useful for sorting document in an admin interface.
+ #
+ # @return[Float<0.0,1.0>]
+ attr_reader :spaminess
+
+ ##
# Retrieves the status of a document back from Defensio.
#
# Please note that this only retrieves the status of the document (like
# it's spaminess, whether it should be allowed or not, etc.) and not the
# content of the request (all of the data in the {#data} hash).
@@ -47,10 +55,11 @@
ret = Defender.call(:get_document, signature)
if ret
document.instance_variable_set(:@saved, true)
document.instance_variable_set(:@allow, ret.last['allow'])
document.instance_variable_set(:@signature, signature)
+ document.instance_variable_set(:@spaminess, ret.last['spaminess'])
document
else
nil
end
@@ -89,9 +98,10 @@
return true if saved?
data = ret.last
@allow = data['allow']
@signature = data['signature']
+ @spaminess = data['spaminess']
@saved = true # This will also return true, since nothing failed as we got here
end