Module: SimpleCaptcha::ModelHelpers::InstanceMethods
- Defined in:
- lib/simple_captcha_active_record.rb
Instance Method Summary collapse
- #save(check_validations = true) ⇒ Object
- #save_with_captcha ⇒ Object
- #valid? ⇒ Boolean
- #valid_with_captcha? ⇒ Boolean
Instance Method Details
#save(check_validations = true) ⇒ Object
79 80 81 82 |
# File 'lib/simple_captcha_active_record.rb', line 79 def save(check_validations=true) self.authenticate_with_captcha = false self.save_without_captcha(check_validations) end |
#save_with_captcha ⇒ Object
72 73 74 75 76 77 |
# File 'lib/simple_captcha_active_record.rb', line 72 def save_with_captcha self.authenticate_with_captcha = true ret = self.save_without_captcha self.authenticate_with_captcha = false ret end |
#valid? ⇒ Boolean
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/simple_captcha_active_record.rb', line 45 def valid? return valid_without_captcha? if RAILS_ENV == 'test' if authenticate_with_captcha ret = valid_without_captcha? if captcha && captcha.upcase.delete(" ") == simple_captcha_value(captcha_key) ret = ret && true else ret = false self.class.instance_variable_get(:@add_to_base) == true ? self.errors.add_to_base(self.class.instance_variable_get(:@captcha_invalid_message)) : self.errors.add(:captcha, self.class.instance_variable_get(:@captcha_invalid_message)) end simple_captcha_passed!(captcha_key) if ret return ret else return valid_without_captcha? end end |
#valid_with_captcha? ⇒ Boolean
64 65 66 67 68 69 70 |
# File 'lib/simple_captcha_active_record.rb', line 64 def valid_with_captcha? return valid_without_captcha? if RAILS_ENV == 'test' self.authenticate_with_captcha = true ret = self.valid? self.authenticate_with_captcha = false ret end |