This project is archived and is in readonly mode.

#2138 ✓resolved
Niels Ganser

Teach ActiveSupport::Memoizable about private methods

Reported by Niels Ganser | March 5th, 2009 @ 06:48 PM

Currently, if you define a private method and later call memoize :your_method, the replacement methods created by Memoizable will be public. E.g.


class Person
  extend ActiveSupport::Memoizable
  private
  def is_bald?; end
  memoize :is_bald?
end

Person.new.is_bald?

will not raise *NoMethodError: private method is_bald?' called*.

The attached patch causes ActiveSupport::Memoizable to prepend all the re-definition of your_method with the private keyword if the original your_method had been a private_instance_method in the first place.

Tests are included.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages