Class: DhEasy::Qa::ValidateExternal

Inherits:
Object
  • Object
show all
Defined in:
lib/dh_easy/qa/validate_external.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, config, outputs, collection_name, options) ⇒ ValidateExternal

Returns a new instance of ValidateExternal.



6
7
8
9
10
11
12
13
# File 'lib/dh_easy/qa/validate_external.rb', line 6

def initialize(data, config, outputs, collection_name, options)
  @data = data
  @rules = config['individual_validations'] if config
  @outputs = outputs
  @collection_name = collection_name
  @options = options
  @errors = { errored_items: [] }
end

Instance Attribute Details

#collection_nameObject (readonly)

Returns the value of attribute collection_name.



4
5
6
# File 'lib/dh_easy/qa/validate_external.rb', line 4

def collection_name
  @collection_name
end

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/dh_easy/qa/validate_external.rb', line 4

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



4
5
6
# File 'lib/dh_easy/qa/validate_external.rb', line 4

def errors
  @errors
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/dh_easy/qa/validate_external.rb', line 4

def options
  @options
end

#outputsObject (readonly)

Returns the value of attribute outputs.



4
5
6
# File 'lib/dh_easy/qa/validate_external.rb', line 4

def outputs
  @outputs
end

#rulesObject (readonly)

Returns the value of attribute rules.



4
5
6
# File 'lib/dh_easy/qa/validate_external.rb', line 4

def rules
  @rules
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dh_easy/qa/validate_external.rb', line 15

def run
  begin
    if data.any?
      ValidateGroups.new(data, nil, collection_name, errors).run
      ValidateRules.new(data, errors, rules).run if rules
    end
    SaveOutput.new(data.count, rules, errors, collection_name, outputs, options).run
    return errors
  rescue StandardError => e
    puts "An error has occurred: #{e}"
    return nil
  end
end