Closed nmertaugh closed 13 years ago
I rarely, if ever, use the Model#[]= method so I hadn't considered this. Thanks for the fix!
I added a test and I took your suggestion of replacing the heredoc with a class_eval block. Good call on that.
I've also added you as an author (https://rubygems.org/gems/immutable_attributes). Thanks for the help!
Excellent, thanks very much Jack! Great gem, I'll definitely be staying involved.
The current immutable_attributes head does not handle the
ActiveRecord::Base#[]=
method that wrapswrite_attribute
as follows:This allows for very easily changing attributes that have been designated immutable:
I am proposing the handling of this by overwriting the
ActiveRecord::Base#[]=
method to first check whether the passed attribute has already been declared immutable.NOTE:
I'm using
class_eval
with a heredoc here instead of a block. If there is a clean way to pass theargs
variable fromImmutableAttributes#attr_immutable
into the new definition of[]=
and use a block forclass_eval
then I am in favor of that.