Class: NiceTextCaptcha::Captcha
- Inherits:
-
Object
- Object
- NiceTextCaptcha::Captcha
- Defined in:
- lib/nice_text_captcha/captcha.rb
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.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/nice_text_captcha/captcha.rb', line 8 def initialize captcha = [ Types::MathsQuestion, Types::LetterPositionQuestion, Types::WordsInListQuestion, Types::WordLengthQuestion, ].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
23 24 25 26 |
# File 'lib/nice_text_captcha/captcha.rb', line 23 def self.hash(obj, answer) str = obj.to_s + answer.to_s + ActionController::Base.[:secret].to_s Digest::SHA2.hexdigest(str) end |