Hide included methods

So, I needed some module methods in one of my controllers:

1
2
3
class FooController < ApplicationController::Base
  include MyModule
end

but the writer of MyModule left the methods public so that they'll show up in FooController.action_methods and be accessible with URLs :(

1
2
3
4
class FooController < ApplicationController::Base
  protected
  include MyModule
end

that doesn't work because the module redefines the default visibility. This is the ticket:

1
2
3
4
class FooController < ApplicationController::Base
  include MyModule
  protected(*MyModule.public_instance_methods(true))
end

Leave a Reply