Sha256: b875fb4bc9696b0b4deff7fa50533fe8a0c05c30d40071ae44fa23674b32e3ec

Contents?: true

Size: 633 Bytes

Versions: 7

Compression:

Stored size: 633 Bytes

Contents

module EasyCaptcha
  module ModelHelpers
    # helper class for ActiveRecord
    def self.included(base) #:nodoc:
      base.extend ClassMethods
    end
    
    module ClassMethods
      # to activate model captcha validation
      def acts_as_easy_captcha
        include InstanceMethods
        attr_writer :captcha, :captcha_verification
      end
    end

    module InstanceMethods
      def captcha
        ""
      end

      def valid_captcha?
        errors.add(:captcha, :invalid) if @captcha.blank? or @captcha_verification.blank? or @captcha.to_s.upcase != @captcha_verification.to_s.upcase 
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
easy_captcha-0.2.5 lib/easy_captcha/model_helpers.rb
easy_captcha-0.2.4 lib/easy_captcha/model_helpers.rb
easy_captcha-0.2.3 lib/easy_captcha/model_helpers.rb
easy_captcha-0.2.2 lib/easy_captcha/model_helpers.rb
easy_captcha-0.2.1 lib/easy_captcha/model_helpers.rb
easy_captcha-0.2.0 lib/easy_captcha/model_helpers.rb
easy_captcha-0.1.9 lib/easy_captcha/model_helpers.rb