class SimpleCaptchaInput

Public Instance Methods

captcha_key(captcha) click to toggle source
# File lib/simple_captcha_reloaded/adapters/formtastic.rb, line 29
def captcha_key(captcha)
  builder.hidden_field :captcha_key, value: captcha[:captcha_id]
end
image_tag(captcha) click to toggle source
# File lib/simple_captcha_reloaded/adapters/formtastic.rb, line 25
def image_tag(captcha)
  template.content_tag(:img, nil, src: captcha[:captcha_url], alt: 'Captcha', class: 'simple-captcha-image')
end
refresh_button(captcha) click to toggle source
# File lib/simple_captcha_reloaded/adapters/formtastic.rb, line 33
def refresh_button(captcha)
  template.content_tag :div, class: 'simple-captcha-reload' do
    template.link_to captcha[:refresh_url], class: options[:captcha][:refresh_button_class], data: {remote: true} do
      I18n.t('simple_captcha_reloaded.refresh_button_html')
    end
  end
end
set_options!() click to toggle source
# File lib/simple_captcha_reloaded/adapters/formtastic.rb, line 14
def set_options!
  default_options = {
    refresh_button: true,
    id: 'simple_captcha_wrapper'
  }
  options[:wrapper_html] ||= {}
  options[:captcha] ||= {}
  options[:captcha].reverse_merge!(default_options)
  options[:wrapper_html][:id] ||= options[:captcha][:id]
end
to_html() click to toggle source
# File lib/simple_captcha_reloaded/adapters/formtastic.rb, line 2
def to_html
  set_options!
  captcha = SimpleCaptchaReloaded.generate_captcha(id: options[:captcha][:id], request: template.request)
  input_wrapping do
    label_html <<
    image_tag(captcha) <<
    captcha_key(captcha) <<
    builder.text_field(method, input_html_options) <<
    refresh_button(captcha)
  end
end