Class: Cloudflare::Turnstile::Rails::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudflare/turnstile/rails/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



8
9
10
11
12
13
14
15
# File 'lib/cloudflare/turnstile/rails/configuration.rb', line 8

def initialize
  @script_url = Cloudflare::SCRIPT_URL
  @site_key = nil
  @secret_key = nil
  @render = nil
  @onload = nil
  @auto_populate_response_in_test_env = true
end

Instance Attribute Details

#auto_populate_response_in_test_envObject

Returns the value of attribute auto_populate_response_in_test_env.



6
7
8
# File 'lib/cloudflare/turnstile/rails/configuration.rb', line 6

def auto_populate_response_in_test_env
  @auto_populate_response_in_test_env
end

#onloadObject

Returns the value of attribute onload.



6
7
8
# File 'lib/cloudflare/turnstile/rails/configuration.rb', line 6

def onload
  @onload
end

#renderObject

Returns the value of attribute render.



6
7
8
# File 'lib/cloudflare/turnstile/rails/configuration.rb', line 6

def render
  @render
end

#script_urlObject

Dynamically build the URL every time, so that config.render and config.onload applied after init take effect.



19
20
21
22
23
24
25
26
27
28
# File 'lib/cloudflare/turnstile/rails/configuration.rb', line 19

def script_url
  return @script_url unless @script_url == Cloudflare::SCRIPT_URL

  # Otherwise, append render/onload if present:
  params = []
  params << "render=#{CGI.escape(@render)}" unless @render.nil?
  params << "onload=#{CGI.escape(@onload)}" unless @onload.nil?

  params.empty? ? Cloudflare::SCRIPT_URL : "#{Cloudflare::SCRIPT_URL}?#{params.join('&')}"
end

#secret_keyObject

Returns the value of attribute secret_key.



6
7
8
# File 'lib/cloudflare/turnstile/rails/configuration.rb', line 6

def secret_key
  @secret_key
end

#site_keyObject

Returns the value of attribute site_key.



6
7
8
# File 'lib/cloudflare/turnstile/rails/configuration.rb', line 6

def site_key
  @site_key
end