Module: ValidationSets::InstanceMethods

Included in:
ActiveRecord::Base
Defined in:
lib/validation_sets.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_validation_setObject (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.new
.use_validation_set(:admin) # Turns on the :admin validation set
.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