Sha256: bdcfc3f7316596c27d3dcf41493abd4a04a8b3143ebd219f7aef904398a4c026
Contents?: true
Size: 907 Bytes
Versions: 2
Compression:
Stored size: 907 Bytes
Contents
module DalliCaptcha module Model extend ActiveSupport::Concern def self.included(base) base.extend(ClassMethods) base.send :validate, :check_captcha base.send :after_save, :delete_captcha base.send :attr_accessor, :captcha, :captcha_key end module ClassMethods end def key_handler @key_handler ||= DalliCaptcha::KeyHandler.new(captcha_key) end def check_captcha if without_captcha? @skip_captcha = false else errors.add(:captcha, DalliCaptcha::options[:error_message]) unless key_handler.valid?(captcha) end end def delete_captcha key_handler.delete end def without_captcha? !!@skip_captcha end def valid_without_captcha? @skip_captcha = true self.valid? end def save_without_captcha @skip_captcha = true self.save end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dalli_captcha-0.1.0 | lib/dalli_captcha/model.rb |
dalli_captcha-0.0.3 | lib/dalli_captcha/model.rb |