Class: ForemanOpenscap::Oval::CheckCollection
- Inherits:
-
Object
- Object
- ForemanOpenscap::Oval::CheckCollection
- Defined in:
- app/services/foreman_openscap/oval/check_collection.rb
Instance Attribute Summary collapse
-
#checks ⇒ Object
readonly
Returns the value of attribute checks.
Instance Method Summary collapse
- #add_check(check) ⇒ Object
- #all_passed? ⇒ Boolean
- #fail_check(check_id, error_data = nil) ⇒ Object
- #find_check(check_id) ⇒ Object
- #find_failed ⇒ Object
-
#initialize(initial_check_attrs = []) ⇒ CheckCollection
constructor
A new instance of CheckCollection.
- #merge(other) ⇒ Object
- #pass_check(check_id) ⇒ Object
- #to_h ⇒ Object
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
#checks ⇒ Object (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
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_failed ⇒ Object
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_h ⇒ Object
40 41 42 |
# File 'app/services/foreman_openscap/oval/check_collection.rb', line 40 def to_h @checks.map(&:to_h) end |