rails/rails — pull request #6831 by teleological (2012-06-22 18:47:08+00:00)
Title: Support initialization of private attributes

ActiveRecord model constructors accept a hash of parameters which are used to invoke the corresponding attribute writer methods. Attribute writers are privately invoked with #send, but they are first screened with #respond_to? to avoid invoking private methods. This precludes the common practice of encapsulating members by allowing them to be initialized at construction but not reassigned after construction.

This patch enables the constructor to invoke private attribute writers by accepting an additional option (:with_private) along with the options which are used to control mass-assignment protection.