Module: ValidatesImmutability::ClassMethods
- Defined in:
- lib/validates_immutability.rb
Instance Method Summary collapse
Instance Method Details
#immutable(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/validates_immutability.rb', line 7 def immutable( = {}) if .key?(:on) raise ArgumentError, "Unknown option :on" end .merge!(:on => :update) error_msg = .delete(:message) || "Updates are not allowed." validate do errors[:base] << error_msg if changed? end end |