Class: ReCaptcha::Configuration
- Inherits:
-
Object
- Object
- ReCaptcha::Configuration
- Defined in:
- lib/re_captcha/configuration.rb
Constant Summary collapse
- API_END_POINT =
'https://www.google.com/recaptcha/'
- SKIPPED_ENVIRONMENTS =
%w(test cucumber)
- LANGUAGE_TABLE =
{ 'en-US' => 'en', 'fr-FR' => 'fr', 'es-ES' => 'es', 'pt-PT' => 'pt-PT', 'it-IT' => 'it', 'en-GB' => 'en-GB', 'de-DE' => 'de', 'pt-BR' => 'pt-BR', 'en-EU' => 'en-GB', 'es-LA' => 'es-419', 'zh-CN' => 'zh-CN', }
Instance Attribute Summary collapse
-
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
-
#deny_on_error ⇒ Object
Returns the value of attribute deny_on_error.
-
#language_table ⇒ Object
Returns the value of attribute language_table.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
-
#public_key ⇒ Object
Returns the value of attribute public_key.
-
#skipped_env ⇒ Object
Returns the value of attribute skipped_env.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #language_code(locale) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
22 23 24 25 26 27 28 29 |
# File 'lib/re_captcha/configuration.rb', line 22 def initialize @api_endpoint = API_END_POINT @skipped_env = SKIPPED_ENVIRONMENTS @public_key = ENV['RECAPTCHA_PUBLIC_KEY'] @private_key = ENV['RECAPTCHA_PRIVATE_KEY'] @language_table = LANGUAGE_TABLE @deny_on_error = false end |
Instance Attribute Details
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
19 20 21 |
# File 'lib/re_captcha/configuration.rb', line 19 def api_endpoint @api_endpoint end |
#deny_on_error ⇒ Object
Returns the value of attribute deny_on_error.
19 20 21 |
# File 'lib/re_captcha/configuration.rb', line 19 def deny_on_error @deny_on_error end |
#language_table ⇒ Object
Returns the value of attribute language_table.
19 20 21 |
# File 'lib/re_captcha/configuration.rb', line 19 def language_table @language_table end |
#private_key ⇒ Object
Returns the value of attribute private_key.
19 20 21 |
# File 'lib/re_captcha/configuration.rb', line 19 def private_key @private_key end |
#public_key ⇒ Object
Returns the value of attribute public_key.
19 20 21 |
# File 'lib/re_captcha/configuration.rb', line 19 def public_key @public_key end |
#skipped_env ⇒ Object
Returns the value of attribute skipped_env.
19 20 21 |
# File 'lib/re_captcha/configuration.rb', line 19 def skipped_env @skipped_env end |
Instance Method Details
#language_code(locale) ⇒ Object
31 32 33 |
# File 'lib/re_captcha/configuration.rb', line 31 def language_code(locale) @language_table[locale.to_s] || 'en' end |
#valid? ⇒ Boolean
35 36 37 |
# File 'lib/re_captcha/configuration.rb', line 35 def valid? !private_key.nil? && !public_key.nil? end |