Class: Class

Inherits:
Object
  • Object
show all
Defined in:
lib/validation_profiler/class_methods.rb

Instance Method Summary collapse

Instance Method Details

#validates(field, rule, attributes = {}) ⇒ Object

DEPRECIATED

do not use, please use ‘extend ValidationProfiler’ instead

Specifies a validation rule to use within a validation profile.

Parameters:

  • field (Symbol)

    The name of the field to validate

  • rule (Symbol)

    The name of the validation rule to use

  • attributes (Hash) (defaults to: {})
    Optional

    A has containing the validation rule options



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/validation_profiler/class_methods.rb', line 9

def validates(field, rule, attributes = {})

  puts "[ValidationProfile] - Method depreciated. Please use 'extend ValidationProfiler' in your validation profile class to access the 'validates' method."

  if !self.class_variable_defined?(:@@validation_rules)
    self.class_variable_set(:@@validation_rules, [])
  end

  validation_rules = self.class_variable_get(:@@validation_rules)
  validation_rules.push({ name: rule, field: field, attributes: attributes })

  self.class_variable_set(:@@validation_rules, validation_rules)

end