Class: RailsCloudflareTurnstile::Configuration
- Inherits:
-
Object
- Object
- RailsCloudflareTurnstile::Configuration
- Defined in:
- lib/rails_cloudflare_turnstile/configuration.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#fail_open ⇒ Object
if true, then a failure to contact cloudflare will allow all requests if false, then a failure to contact cloudflare will block all requests defaults to true.
-
#mock_enabled ⇒ Object
Returns the value of attribute mock_enabled.
-
#secret_key ⇒ Object
secret key.
-
#site_key ⇒ Object
site key (your public key).
-
#size ⇒ Object
size for the widget (:normal, :compact, or :flexible).
-
#theme ⇒ Object
theme for the widget (:auto, :light, or :dark).
-
#timeout ⇒ Object
Timeout for operations with Cloudflare.
-
#validation_url ⇒ Object
Returns the value of attribute validation_url.
Instance Method Summary collapse
- #disabled? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 29 def initialize @site_key = nil @secret_key = nil @fail_open = true @enabled = nil @mock_enabled = nil @timeout = 5.0 @size = :normal @theme = :auto @validation_url = "https://challenges.cloudflare.com/turnstile/v0/siteverify" end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
25 26 27 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 25 def enabled @enabled end |
#fail_open ⇒ Object
if true, then a failure to contact cloudflare will allow all requests if false, then a failure to contact cloudflare will block all requests defaults to true
12 13 14 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 12 def fail_open @fail_open end |
#mock_enabled ⇒ Object
Returns the value of attribute mock_enabled.
27 28 29 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 27 def mock_enabled @mock_enabled end |
#secret_key ⇒ Object
secret key
7 8 9 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 7 def secret_key @secret_key end |
#site_key ⇒ Object
site key (your public key)
4 5 6 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 4 def site_key @site_key end |
#size ⇒ Object
size for the widget (:normal, :compact, or :flexible)
20 21 22 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 20 def size @size end |
#theme ⇒ Object
theme for the widget (:auto, :light, or :dark)
23 24 25 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 23 def theme @theme end |
#timeout ⇒ Object
Timeout for operations with Cloudflare
17 18 19 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 17 def timeout @timeout end |
#validation_url ⇒ Object
Returns the value of attribute validation_url.
14 15 16 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 14 def validation_url @validation_url end |
Instance Method Details
#disabled? ⇒ Boolean
49 50 51 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 49 def disabled? @enabled == false end |
#validate! ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/rails_cloudflare_turnstile/configuration.rb', line 41 def validate! raise "Must set site key" if @site_key.nil? raise "Must set secret key" if @secret_key.nil? @size = @size.to_sym raise "Size must be one of ':normal', ':compact' or ':flexible'" unless [:normal, :compact, :flexible].include? @size raise "Theme must be one of :auto, :light, or :dark" unless [:auto, :light, :dark].include? @theme end |