module TurboGoogleRecaptcha
Constants
- VERSION
Public Class Methods
compose_uri(token)
click to toggle source
# File lib/turbo_google_recaptcha.rb, line 52 def self.compose_uri(token) URI( "https://www.google.com/recaptcha/api/siteverify?"\ "secret=#{self.secret_key}&response=#{token}" ) end
get_humanity_detailed(token, action, minimum_score = self.minimum_score, model = nil)
click to toggle source
# File lib/turbo_google_recaptcha.rb, line 27 def self.get_humanity_detailed(token, action, minimum_score = self.minimum_score, model = nil) validator = TurboGoogleRecaptcha::Validator.new( token: token, action: action, minimum_score: minimum_score ) is_valid = validator.call if model && !is_valid model.errors.add(:base, self.i18n("turbo_google_recaptcha.errors.verification_human", "Looks like you are not a human")) end { is_human: is_valid, score: validator.score, model: model } end
human?(token, action, minimum_score = self.minimum_score, model = nil)
click to toggle source
# File lib/turbo_google_recaptcha.rb, line 12 def self.human?(token, action, minimum_score = self.minimum_score, model = nil) is_valid = TurboGoogleRecaptcha::Validator.new( token: token, action: action, minimum_score: minimum_score ).call if model && !is_valid model.errors.add(:base, self.i18n("turbo_google_recaptcha.errors.verification_human", "Looks like you are not a human")) end is_valid end
i18n(key, default)
click to toggle source
# File lib/turbo_google_recaptcha.rb, line 44 def self.i18n(key, default) if defined?(I18n) I18n.translate(key, default: default) else default end end
setup() { |self| ... }
click to toggle source
# File lib/turbo_google_recaptcha.rb, line 8 def self.setup yield(self) end