I have a gem:
# in /Library/Ruby/Gems/1.8/gems/my_gem-1.0.0/lib/my_gem.rb
module MyGem
def do_stuff
..
end
end
And I loaded it in Rails:
# in [rails_root]/config/environment.rb:
config.gem 'my_gem', :version => '1.0.0'
And used it:
# in [rails_root]/app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
include MyGem
end
But I need to monkey-patch it a bit in an environment-specific way:
# in [rails_root]/config/environments/development.rb:
MyGem.class_eval do
def do_stuff
raise 'Ack! - just testing'
end
end
Unfortunately, MyGem
reloads on every request, so my monkey-patching is useless.
I've checked load_once_paths
:
ActiveSupport::Dependencies.load_once_paths
# => ["/Library/Ruby/Gems/1.8/gems/my_gem-1.0.0/lib", "other stuff"]
Any idea how I can get the effect I want?