Sha256: ff1b7b45b19ea027c02119ca410404a9f965e4982bf4c8effbc60aa0017fcbe3

Contents?: true

Size: 748 Bytes

Versions: 14

Compression:

Stored size: 748 Bytes

Contents

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

    module InstanceMethods #:nodoc:

      def captcha  #:nodoc:
        ""
      end

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

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
easy_captcha_rails-0.6.6.1 lib/easy_captcha/model_helpers.rb
easy_captcha-0.6.5 lib/easy_captcha/model_helpers.rb
easy_captcha-ftbpro-0.6.4 lib/easy_captcha/model_helpers.rb
easy_captcha-0.6.4 lib/easy_captcha/model_helpers.rb
easy_captcha-0.6.3 lib/easy_captcha/model_helpers.rb
easy_captcha-0.6.2 lib/easy_captcha/model_helpers.rb
easy_captcha-0.6.1 lib/easy_captcha/model_helpers.rb
easy_captcha-0.5.1 lib/easy_captcha/model_helpers.rb
easy_captcha-0.5.0 lib/easy_captcha/model_helpers.rb
easy_captcha-0.4.7 lib/easy_captcha/model_helpers.rb
easy_captcha-0.4.5 lib/easy_captcha/model_helpers.rb
easy_captcha-0.4.4 lib/easy_captcha/model_helpers.rb
easy_captcha-0.4.3 lib/easy_captcha/model_helpers.rb
easy_captcha-0.4.2 lib/easy_captcha/model_helpers.rb