Module: Vanguard::InstanceMethods

Includes:
Adamantium
Defined in:
lib/vanguard/instance_methods.rb

Overview

Instance level mixins

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#resourceObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return validated resource

Returns:

  • (Object)


12
13
14
# File 'lib/vanguard/instance_methods.rb', line 12

def resource
  @resource
end

Instance Method Details

#on(attribute_name) ⇒ Enumerable<Violation>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return violations on attribute name

Parameters:

  • attribute_name (Symbol)

Returns:



47
48
49
# File 'lib/vanguard/instance_methods.rb', line 47

def on(attribute_name)
  result.on(attribute_name)
end

#resultViolationSet

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return violation set

Returns:

  • (ViolationSet)


20
21
22
# File 'lib/vanguard/instance_methods.rb', line 20

def result
  self.class.validator.evaluate(resource)
end

#valid?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if validator is valid

Returns:

  • (true)

    if valid

  • (false)

    otherwise



35
36
37
# File 'lib/vanguard/instance_methods.rb', line 35

def valid?
  result.valid?
end

#violationsEnumerable<Violation>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return violations

Returns:



57
58
59
# File 'lib/vanguard/instance_methods.rb', line 57

def violations
  result.violations
end