Class: Hcaptcha::Configuration
- Inherits:
-
Object
- Object
- Hcaptcha::Configuration
- Defined in:
- lib/hcaptcha/configuration.rb
Overview
This class enables detailed configuration of the hcaptcha services.
By calling
Hcaptcha.configuration # => instance of Hcaptcha::Configuration
or
Hcaptcha.configure do |config|
config # => instance of Hcaptcha::Configuration
end
you are able to perform configuration updates.
Your are able to customize all attributes listed below. All values have sensitive default and will very likely not need to be changed.
Please note that the site and secret key for the hCaptcha API Access have no useful default value. The keys may be set via the Shell enviroment or using this configuration. Settings within this configuration always take precedence.
Setting the keys with this Configuration
Hcaptcha.configure do |config|
config.site_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
config.secret_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
end
Constant Summary collapse
- DEFAULTS =
{ 'server_url' => 'https://hcaptcha.com/1/api.js', 'verify_url' => 'https://hcaptcha.com/siteverify' }.freeze
Instance Attribute Summary collapse
- #api_server_url ⇒ Object
-
#default_env ⇒ Object
Returns the value of attribute default_env.
-
#handle_timeouts_gracefully ⇒ Object
Returns the value of attribute handle_timeouts_gracefully.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
-
#site_key ⇒ Object
Returns the value of attribute site_key.
-
#skip_verify_env ⇒ Object
Returns the value of attribute skip_verify_env.
- #verify_url ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
:nodoc:.
- #secret_key! ⇒ Object
- #site_key! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
:nodoc:
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/hcaptcha/configuration.rb', line 41 def initialize #:nodoc: @default_env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || (Rails.env if defined? Rails.env) @skip_verify_env = %w[test cucumber] @handle_timeouts_gracefully = true @secret_key = ENV['HCAPTCHA_SECRET_KEY'] @site_key = ENV['HCAPTCHA_SITE_KEY'] @verify_url = nil @api_server_url = nil end |
Instance Attribute Details
#api_server_url ⇒ Object
60 61 62 |
# File 'lib/hcaptcha/configuration.rb', line 60 def api_server_url @api_server_url || DEFAULTS.fetch('server_url') end |
#default_env ⇒ Object
Returns the value of attribute default_env.
38 39 40 |
# File 'lib/hcaptcha/configuration.rb', line 38 def default_env @default_env end |
#handle_timeouts_gracefully ⇒ Object
Returns the value of attribute handle_timeouts_gracefully.
38 39 40 |
# File 'lib/hcaptcha/configuration.rb', line 38 def handle_timeouts_gracefully @handle_timeouts_gracefully end |
#hostname ⇒ Object
Returns the value of attribute hostname.
38 39 40 |
# File 'lib/hcaptcha/configuration.rb', line 38 def hostname @hostname end |
#proxy ⇒ Object
Returns the value of attribute proxy.
38 39 40 |
# File 'lib/hcaptcha/configuration.rb', line 38 def proxy @proxy end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
38 39 40 |
# File 'lib/hcaptcha/configuration.rb', line 38 def secret_key @secret_key end |
#site_key ⇒ Object
Returns the value of attribute site_key.
38 39 40 |
# File 'lib/hcaptcha/configuration.rb', line 38 def site_key @site_key end |
#skip_verify_env ⇒ Object
Returns the value of attribute skip_verify_env.
38 39 40 |
# File 'lib/hcaptcha/configuration.rb', line 38 def skip_verify_env @skip_verify_env end |
#verify_url ⇒ Object
64 65 66 |
# File 'lib/hcaptcha/configuration.rb', line 64 def verify_url @verify_url || DEFAULTS.fetch('verify_url') end |
Instance Method Details
#secret_key! ⇒ Object
52 53 54 |
# File 'lib/hcaptcha/configuration.rb', line 52 def secret_key! secret_key || raise(HcaptchaError, "No secret key specified.") end |
#site_key! ⇒ Object
56 57 58 |
# File 'lib/hcaptcha/configuration.rb', line 56 def site_key! site_key || raise(HcaptchaError, "No site key specified.") end |