public
Description: Rails Plugin - specify attributes within a model that can be set but not modified
Homepage: http://6brand.com
Clone URL: git://github.com/JackDanger/immutable_attributes.git
JackDanger (author)
Thu Mar 27 13:09:59 -0700 2008
commit  611798732ebd560ac6c759976e9eff00dee4f168
tree    1b9b7144dfcdf026b91f65183d1d348a850b65a4
parent  75c1e4a3bd82f5a7286b9e5fdfb6e5f4a2829834
100644 18 lines (10 sloc) 0.528 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
 
ImmutableAttributes
===================
 
When you want to prevent certain attributes from being changed once set you can declare them as immutable:
 
class MyModel < ActiveRecord::Base
  attr_immutable :permalink, :param_identifier
end
 
When MyModel.find(:first).permalink = 'anything' is called it will raise an ImmutableAttributeError
MyModel.new.permalink = 'works!' will properly set the value because the record is unsaved.
 
Created by Jack Danger Canty @ http://6brand.com
Released under the same licence as Rails (MIT)