Module: Hcaptcha::Helpers
- Defined in:
- lib/hcaptcha/helpers.rb
Constant Summary collapse
- DEFAULT_ERRORS =
{ hcaptcha_unreachable: 'Oops, we failed to validate your hCaptcha response. Please try again.', verification_failed: 'hCaptcha verification failed, please try again.' }.freeze
- DEFAULT_OPTIONS =
{ external_script: true, script: true, script_async: true, script_defer: true, theme: :dark }.freeze
Class Method Summary collapse
Class Method Details
.hcaptcha(options) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/hcaptcha/helpers.rb', line 17 def self.hcaptcha() if .key?(:stoken) raise(HcaptchaError, "Secure Token is deprecated. Please remove 'stoken' from your calls to hcaptcha_tags.") end if .key?(:ssl) raise(HcaptchaError, "SSL is now always true. Please remove 'ssl' from your calls to hcaptcha_tags.") end html = () html.respond_to?(:html_safe) ? html.html_safe : html end |
.to_error_message(key) ⇒ Object
29 30 31 32 |
# File 'lib/hcaptcha/helpers.rb', line 29 def self.(key) default = DEFAULT_ERRORS.fetch(key) { raise ArgumentError "Unknown hCaptcha error - #{key}" } ("hcaptcha.errors.#{key}", default) end |
.to_message(_key, default) ⇒ Object
35 36 37 |
# File 'lib/hcaptcha/helpers.rb', line 35 def self.(key, default) I18n.translate(key, default: default) end |