class Captcher::BaseCaptcha

Constants

SESSION_KEY

Attributes

name[RW]
config[RW]
payload[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/captcher/base_captcha.rb, line 20
def initialize(options = {})
  options = options.with_indifferent_access
  @config = options[:config] if options[:config]
  @payload = options[:payload] if options[:payload]
  after_initialize
end
restore(session) click to toggle source
# File lib/captcher/base_captcha.rb, line 8
def restore(session)
  state = session[SESSION_KEY]
  new(state) if state
end
restore_or_create(config, session) click to toggle source
# File lib/captcher/base_captcha.rb, line 13
def restore_or_create(config, session)
  restore(session) || new(config: config).store(session)
end

Public Instance Methods

after_initialize() click to toggle source
# File lib/captcher/base_captcha.rb, line 27
def after_initialize; end
own_config() click to toggle source
# File lib/captcher/base_captcha.rb, line 34
def own_config
  @own_config ||= @config[self.class.name.to_sym]
end
represent(format = :html, options = {}) click to toggle source
# File lib/captcher/base_captcha.rb, line 38
def represent(format = :html, options = {})
  raise NotImplementedError
end
store(session) click to toggle source
# File lib/captcher/base_captcha.rb, line 29
def store(session)
  session[SESSION_KEY] = { payload: payload, config: config }
  self
end
validate(confirmation) click to toggle source
# File lib/captcher/base_captcha.rb, line 42
def validate(confirmation)
  raise NotImplementedError
end