lib/tiny_captcha/engine.rb in tiny_captcha-0.0.1 vs lib/tiny_captcha/engine.rb in tiny_captcha-0.0.3

- old
+ new

@@ -1,5 +1,32 @@ +# -*- encoding : utf-8 -*- +require 'rails' +require 'tiny_captcha' + module TinyCaptcha class Engine < ::Rails::Engine - isolate_namespace TinyCaptcha + config.before_initialize do + ActiveSupport.on_load :active_record do + ActiveRecord::Base.send(:include, TinyCaptcha::ModelHelpers) + end + end + + config.after_initialize do + ActionView::Base.send(:include, TinyCaptcha::ViewHelper) + ActionView::Helpers::FormBuilder.send(:include, TinyCaptcha::FormBuilder) + + ActionController::Base.send :include, ::TinyCaptcha::ControllerHelpers + + if Object.const_defined?("Formtastic") + if Formtastic.const_defined?("Helpers") + Formtastic::Helpers::FormHelper.builder = TinyCaptcha::CustomFormBuilder + else + Formtastic::SemanticFormHelper.builder = TinyCaptcha::CustomFormBuilder + end + end + end + + config.app_middleware.use TinyCaptcha::Middleware end end + +