This project is archived and is in readonly mode.

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
- 
            
         Ryan Angilly March 6th, 2009 @ 12:07 AM+1 I've never memoized a private method, but would expect it to stay private. 
- 
         
- 
         Pratik March 6th, 2009 @ 02:41 PM- Assigned user set to Pratik
- Milestone cleared.
 
- 
         Repository March 6th, 2009 @ 02:44 PM- State changed from new to resolved
 (from [c67d25e3c4e636d7c94909a7398231a634accf46]) Ensure ActiveSupport::Memoizable respects private methods. [#2138 state:resolved] Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co... 
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
- 
         2138 
          Teach ActiveSupport::Memoizable about private methods
        (from [c67d25e3c4e636d7c94909a7398231a634accf46]) Ensure
... 2138 
          Teach ActiveSupport::Memoizable about private methods
        (from [c67d25e3c4e636d7c94909a7398231a634accf46]) Ensure
...
 Niels Ganser
      Niels Ganser
 Pratik
      Pratik
 Ryan Angilly
      Ryan Angilly