Module Defensio::ActsAs::InstanceMethods
In: lib/defensio/acts_as.rb

Methods

Public Class methods

[Source]

     # File lib/defensio/acts_as.rb, line 114
114:       def self.included(base)
115:         base.class_eval do
116:           alias_method :report_as_spam, :report_as_false_negative
117:           alias_method :report_as_ham, :report_as_false_positive
118:         end
119:       end

Public Instance methods

[Source]

     # File lib/defensio/acts_as.rb, line 153
153:       def announce_article
154:         announce_when = self.class.defensio_options[:announce_when]
155:         announced_field = self.class.defensio_fields(:announced)
156:         
157:         raise Defensio::Error, "announced field not found" unless respond_to? announced_field
158:         
159:         return unless send(announce_when) && !send(announced_field)
160:         
161:         announce_article!
162:         
163:         self.announced = true
164:         save(false)
165:       end

[Source]

     # File lib/defensio/acts_as.rb, line 167
167:       def announce_article!
168:         fields = {}
169:         
170:         fields.merge! extract_optional_fields_value(self, :author, :author_email, :title, :content, :prefix => 'article_')
171:         fields.merge! extract_optional_fields_value(self, :permalink)
172:         
173:         response = nil
174:         log_and_ignore_error do
175:           response = self.class.defensio.announce_article fields
176:         end
177:         
178:         if response
179:           raise Defensio::Error, response.message unless response.success?
180:         end
181:       end

[Source]

     # File lib/defensio/acts_as.rb, line 121
121:       def audit_comment
122:         raise Defensio::Error,
123:               "You have to pass the current request environement:\n\t@comment.env = request.env" unless @env
124:         
125:         article_field = self.class.defensio_fields(:article)
126:         raise Defensio::Error,
127:               "You must specify an assiociated object which acts_as_defensio_article" unless respond_to? article_field
128:         article = send article_field
129:         
130:         fields = { :user_ip      => @env['REMOTE_ADDR'],
131:                    :referrer     => @env['HTTP_REFERER'],
132:                    :article_date => convert_to_defensio_date(article.created_at),
133:                    :comment_type => self.class.comment_type }
134:         
135:         fields.merge! extract_optional_fields_value(self, :author, :content, :title, :author_email, :author_url, :prefix => 'comment_')
136:         fields.merge! extract_optional_fields_value(self, :user_logged_in, :trusted_user)
137:         fields.merge! extract_optional_fields_value(article, :permalink)
138: 
139:         response = nil
140:         log_and_ignore_error do
141:           response = self.class.defensio.audit_comment fields
142:         end
143:         
144:         if response
145:           raise Defensio::Error, response.message unless response.success?
146:           self.signature = response.signature
147:           self.spam      = response.spam
148:           self.spaminess = response.spaminess
149:           save(false)
150:         end
151:       end

[Source]

     # File lib/defensio/acts_as.rb, line 183
183:       def env=(env)
184:         @env = env
185:       end

[Source]

     # File lib/defensio/acts_as.rb, line 187
187:       def report_as_false_negative
188:         log_and_ignore_error do
189:           self.class.defensio.report_false_negatives :signatures => self.signature
190:         end
191:         self.spam      = true
192:         self.spaminess = 1.0
193:         save(false)
194:       end

[Source]

     # File lib/defensio/acts_as.rb, line 196
196:       def report_as_false_positive
197:         log_and_ignore_error do
198:           self.class.defensio.report_false_positives :signatures => self.signature
199:         end
200:         self.spam      = false
201:         self.spaminess = 0.0
202:         save(false)
203:       end

[Validate]