Consider I have this following model definition, I want a particular property which should be constant from the moment it has been created
class A
property :a1, String, :freeze => true
end
Is there something like this? or may be using callbacks ?
Try the following:
The initializer internally delegates to normal attribute writers, so when you initialize the attribute via
YourModel.new(:a1 => "Your value")you cannot change it withyour_instance.a1 = "your value".. But when you create a fresh instance.instance = YourModel.newyou can assign onceinstance.a1 = "Your Value".