Class: NiceTextCaptcha::Captcha
- Inherits:
-
Object
- Object
- NiceTextCaptcha::Captcha
- Defined in:
- lib/nice_text_captcha/captcha.rb
Constant Summary collapse
- NICE_TEXT_CAPTCHA_TYPE_DEFAULTS =
[ Types::FixedQuestion, Types::MathsQuestion, Types::LetterPositionQuestion, Types::WordsInListQuestion, Types::WordLengthQuestion, ]
Instance Attribute Summary collapse
-
#answers ⇒ Object
readonly
Returns the value of attribute answers.
-
#question ⇒ Object
readonly
Returns the value of attribute question.
Class Method Summary collapse
Instance Method Summary collapse
- #encrypted_answers_for(object_name) ⇒ Object
-
#initialize ⇒ Captcha
constructor
A new instance of Captcha.
Constructor Details
#initialize ⇒ Captcha
Returns a new instance of Captcha.
16 17 18 19 20 |
# File 'lib/nice_text_captcha/captcha.rb', line 16 def initialize captcha = (NICE_TEXT_CAPTCHA_TYPES rescue NICE_TEXT_CAPTCHA_TYPE_DEFAULTS).rand.new @question = captcha.question @answers = captcha.answers end |
Instance Attribute Details
#answers ⇒ Object (readonly)
Returns the value of attribute answers.
6 7 8 |
# File 'lib/nice_text_captcha/captcha.rb', line 6 def answers @answers end |
#question ⇒ Object (readonly)
Returns the value of attribute question.
5 6 7 |
# File 'lib/nice_text_captcha/captcha.rb', line 5 def question @question end |
Class Method Details
.hash(obj, answer) ⇒ Object
26 27 28 29 |
# File 'lib/nice_text_captcha/captcha.rb', line 26 def self.hash(obj, answer) str = obj.to_s + answer.to_s + ActionController::Base.[:secret].to_s Digest::SHA2.hexdigest(str) end |