Module: ActsAsTextcaptcha::Textcaptcha

Defined in:
lib/acts_as_textcaptcha/textcaptcha.rb

Defined Under Namespace

Modules: InstanceMethods

Instance Method Summary collapse

Instance Method Details

#acts_as_textcaptcha(options = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/acts_as_textcaptcha/textcaptcha.rb', line 11

def acts_as_textcaptcha(options = nil)
  cattr_accessor :textcaptcha_config
  attr_accessor :textcaptcha_question, :textcaptcha_answer, :textcaptcha_key

  # ensure these attrs are accessible (Rails 3)
  attr_accessible :textcaptcha_answer, :textcaptcha_key if respond_to?(:accessible_attributes) && respond_to?(:attr_accessible)

  self.textcaptcha_config = build_textcaptcha_config(options).symbolize_keys!

  validate :validate_textcaptcha, if: :perform_textcaptcha?

  include InstanceMethods
end