Module: Maestro::Validator

Included in:
Cloud::Base, Node::Base, Role
Defined in:
lib/maestro/validator.rb

Overview

The Validator mixin provides methods for performing validation and reporting validation errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#validObject (readonly)

whether this object is valid or not. defaults to true



6
7
8
# File 'lib/maestro/validator.rb', line 6

def valid
  @valid
end

#validation_errorsObject (readonly)

the collection of validation error strings. if valid is false, this should contain details as to why the object is invalid



8
9
10
# File 'lib/maestro/validator.rb', line 8

def validation_errors
  @validation_errors
end

Instance Method Details

#initializeObject



10
11
12
13
# File 'lib/maestro/validator.rb', line 10

def initialize
  @validation_errors = Array.new
  @valid = true
end

#invalidate(error_str) ⇒ Object

sets this object’s valid attribute to false, and records the given validation error string in the validation_errors attribute



27
28
29
30
# File 'lib/maestro/validator.rb', line 27

def invalidate(error_str)
  @valid = false
  @validation_errors << error_str
end

#valid?Boolean

returns whether this object is valid or not

Returns:

  • (Boolean)


21
22
23
# File 'lib/maestro/validator.rb', line 21

def valid?
  @valid
end

#validateObject

calls the validate_internal method, which classes including this Module should implement



16
17
18
# File 'lib/maestro/validator.rb', line 16

def validate
  validate_internal
end