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
Search Repo:
100644 16 lines (10 sloc) 0.528 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
 
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)