Module: NiceTextCaptcha::ActiveRecordExtensions

Defined in:
lib/nice_text_captcha/active_record_extensions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nice_text_captchaObject

Returns the value of attribute nice_text_captcha.



5
6
7
# File 'lib/nice_text_captcha/active_record_extensions.rb', line 5

def nice_text_captcha
  @nice_text_captcha
end

#nice_text_captcha_responsesObject

Returns the value of attribute nice_text_captcha_responses.



6
7
8
# File 'lib/nice_text_captcha/active_record_extensions.rb', line 6

def nice_text_captcha_responses
  @nice_text_captcha_responses
end

Instance Method Details

#check_nice_text_captchaObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/nice_text_captcha/active_record_extensions.rb', line 8

def check_nice_text_captcha
  
  captcha_successful = @nice_text_captcha_responses.nil?
  @nice_text_captcha_responses.each do |response|
    captcha_successful = true if Captcha.hash(self.class.to_s.underscore, @nice_text_captcha.strip.downcase) == response
  end if @nice_text_captcha_responses
  
  if !captcha_successful
    errors.add_to_base(nice_text_captcha_failure_message)
  end
    
end