Module: InvisibleCaptcha::ControllerExt
- Defined in:
- lib/invisible_captcha/controller_ext.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #default_on_spam ⇒ Object
- #detect_spam(options = {}) ⇒ Object
- #invisible_captcha?(options = {}) ⇒ Boolean
- #on_spam_action(options = {}) ⇒ Object
Instance Method Details
#default_on_spam ⇒ Object
25 26 27 |
# File 'lib/invisible_captcha/controller_ext.rb', line 25 def default_on_spam head(200) end |
#detect_spam(options = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/invisible_captcha/controller_ext.rb', line 11 def detect_spam( = {}) if invisible_captcha?() on_spam_action() end end |
#invisible_captcha?(options = {}) ⇒ Boolean
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/invisible_captcha/controller_ext.rb', line 29 def invisible_captcha?( = {}) honeypot = [:honeypot] scope = [:scope] || controller_name.singularize if honeypot # If honeypot is presented, search for: # - honeypot: params[:subtitle] # - honeypot with scope: params[:topic][:subtitle] if params[honeypot].present? || (params[scope] && params[scope][honeypot].present?) return true end else InvisibleCaptcha.honeypots.each do |field| return true if params[field].present? end end false end |
#on_spam_action(options = {}) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/invisible_captcha/controller_ext.rb', line 17 def on_spam_action( = {}) if action = [:on_spam] send(action) else default_on_spam end end |