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
22
23
# File 'lib/freno/client/preconditions.rb', line 17

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

#reportObject

Raises:



25
26
27
# File 'lib/freno/client/preconditions.rb', line 25

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