Class: Freno::Client::Preconditions::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/freno/client/preconditions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChecker

Returns a new instance of Checker.



13
14
15
# File 'lib/freno/client/preconditions.rb', line 13

def initialize
  @errors = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



11
12
13
# File 'lib/freno/client/preconditions.rb', line 11

def errors
  @errors
end

Instance Method Details

#present(args = {}) ⇒ Object



17
18
19
20
21
# File 'lib/freno/client/preconditions.rb', line 17

def present(args = {})
  args.each do |arg, value|
    errors << "#{arg} should be present" unless value
  end
end

#reportObject

Raises:



23
24
25
# File 'lib/freno/client/preconditions.rb', line 23

def report
  raise PreconditionNotMet, errors.join("\n") unless errors.empty?
end