Class: ForemanOpenscap::Oval::CheckCollection

Inherits:
Object
  • Object
show all
Defined in:
app/services/foreman_openscap/oval/check_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(initial_check_attrs = []) ⇒ CheckCollection

Returns a new instance of CheckCollection.



6
7
8
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 6

def initialize(initial_check_attrs = [])
  @checks = initial_check_attrs.map { |hash| SetupCheck.new hash }
end

Instance Attribute Details

#checksObject (readonly)

Returns the value of attribute checks.



4
5
6
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 4

def checks
  @checks
end

Instance Method Details

#add_check(check) ⇒ Object



30
31
32
33
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 30

def add_check(check)
  @checks << check
  self
end

#all_passed?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 10

def all_passed?
  @checks.all?(&:passed?)
end

#fail_check(check_id, error_data = nil) ⇒ Object



22
23
24
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 22

def fail_check(check_id, error_data = nil)
  find_check(check_id).fail_with! error_data
end

#find_check(check_id) ⇒ Object



14
15
16
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 14

def find_check(check_id)
  @checks.find { |item| item.id == check_id }
end

#find_failedObject



18
19
20
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 18

def find_failed
  @checks.select(&:failed?)
end

#merge(other) ⇒ Object



35
36
37
38
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 35

def merge(other)
  @checks = @checks.concat other.checks
  self
end

#pass_check(check_id) ⇒ Object



26
27
28
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 26

def pass_check(check_id)
  find_check(check_id).pass!
end

#to_hObject



40
41
42
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 40

def to_h
  @checks.map(&:to_h)
end