Skip to content

Commit

Permalink
Merge pull request #268 from ericproulx/lazy_load
Browse files Browse the repository at this point in the history
LazyLoad through ActiveSupport.on_load
  • Loading branch information
grosser authored Apr 17, 2018
2 parents cf2b9f8 + 930133e commit 2ef3b8f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
9 changes: 7 additions & 2 deletions lib/recaptcha.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
require 'recaptcha/configuration'
require 'recaptcha/client_helper'
require 'recaptcha/verify'
require 'uri'
require 'net/http'

if defined?(Rails)
require 'recaptcha/railtie'
else
require 'recaptcha/client_helper'
require 'recaptcha/verify'
end

module Recaptcha
CONFIG = {
'server_url' => 'https://www.google.com/recaptcha/api.js',
Expand Down
10 changes: 0 additions & 10 deletions lib/recaptcha/rails.rb

This file was deleted.

15 changes: 15 additions & 0 deletions lib/recaptcha/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Recaptcha
class Railtie < Rails::Railtie
initializer :recaptcha do
ActiveSupport.on_load(:action_view) do
require 'recaptcha/client_helper'
include Recaptcha::ClientHelper
end

ActiveSupport.on_load(:action_controller) do
require 'recaptcha/verify'
include Recaptcha::Verify
end
end
end
end

0 comments on commit 2ef3b8f

Please sign in to comment.