Class: Recaptcha::Verify::VerifyResultV3

Inherits:
VerifyResult show all
Defined in:
lib/recaptcha/verify/verify_result.rb

Instance Attribute Summary

Attributes inherited from VerifyResult

#errors, #response

Instance Method Summary collapse

Methods inherited from VerifyResult

#hostname_valid?

Constructor Details

#initialize(verify_response, hostname, action) ⇒ VerifyResultV3


53
54
55
56
# File 'lib/recaptcha/verify/verify_result.rb', line 53

def initialize(verify_response, hostname, action)
  super(verify_response, hostname)
  @expected_action = action
end

Instance Method Details

#action_valid?Boolean


71
72
73
74
75
76
# File 'lib/recaptcha/verify/verify_result.rb', line 71

def action_valid?
  case @expected_action
  when nil, FalseClass then true
  else action == @expected_action
  end
end

#valid?Boolean


61
62
63
64
65
66
67
68
69
# File 'lib/recaptcha/verify/verify_result.rb', line 61

def valid?
  super
  return false unless response.success?

  unless action_valid?
    @errors << "Action '#{action}' did not match '#{@expected_action}'"
  end
  @errors.none?
end