Module: ValidationSets::InstanceMethods
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/validation_sets.rb
Instance Attribute Summary collapse
-
#_validation_set ⇒ Object
readonly
Returns the value of attribute _validation_set.
Instance Method Summary collapse
-
#use_validation_set(set) ⇒ Object
Set the active validation set on the model.
Instance Attribute Details
#_validation_set ⇒ Object (readonly)
Returns the value of attribute _validation_set.
60 61 62 |
# File 'lib/validation_sets.rb', line 60 def _validation_set @_validation_set end |
Instance Method Details
#use_validation_set(set) ⇒ Object
Set the active validation set on the model. After calling this both the global as well as the validations defined in the set will run.
Raises an exception when asked to use an unknown validation set.
Example:
account = Account.new
account.use_validation_set(:admin) # Turns on the :admin validation set
account.use_validation_set(nil) # Turns off all validation sets
72 73 74 75 76 77 78 |
# File 'lib/validation_sets.rb', line 72 def use_validation_set(set) if self.class.validation_set_defined?(set) @_validation_set = set else raise ArgumentError, "There is no validation set `#{set}'" end end |