Module: HoneypotCaptcha::SpamProtection
- Defined in:
- lib/honeypot-captcha.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #honeypot_fields ⇒ Object
- #honeypot_string ⇒ Object
- #honeypot_style_class ⇒ Object
- #protect_from_spam ⇒ Object
Class Method Details
.included(base) ⇒ Object
:nodoc:
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/honeypot-captcha.rb', line 21 def self.included(base) # :nodoc: base.send :helper_method, :honeypot_fields base.send :helper_method, :honeypot_string base.send :helper_method, :honeypot_style_class if base.respond_to? :before_action base.send :prepend_before_action, :protect_from_spam, :only => [:create, :update] elsif base.respond_to? :before_filter base.send :prepend_before_filter, :protect_from_spam, :only => [:create, :update] end end |
Instance Method Details
#honeypot_fields ⇒ Object
5 6 7 |
# File 'lib/honeypot-captcha.rb', line 5 def honeypot_fields { :a_comment_body => 'Do not fill in this field' } end |
#honeypot_string ⇒ Object
9 10 11 |
# File 'lib/honeypot-captcha.rb', line 9 def honeypot_string 'hp' end |
#honeypot_style_class ⇒ Object
13 14 15 |
# File 'lib/honeypot-captcha.rb', line 13 def honeypot_style_class nil end |
#protect_from_spam ⇒ Object
17 18 19 |
# File 'lib/honeypot-captcha.rb', line 17 def protect_from_spam head :ok if honeypot_fields.any? { |f,l| !params[f].blank? } end |