Class: ForemanOpenscap::Oval::SetupCheck
- Inherits:
-
Object
- Object
- ForemanOpenscap::Oval::SetupCheck
- Defined in:
- app/services/foreman_openscap/oval/setup_check.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #fail! ⇒ Object
- #fail_msg ⇒ Object
- #fail_with!(fail_data) ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(hash) ⇒ SetupCheck
constructor
A new instance of SetupCheck.
- #pass! ⇒ Object
- #passed? ⇒ Boolean
- #skipped? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(hash) ⇒ SetupCheck
Returns a new instance of SetupCheck.
6 7 8 9 10 11 12 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 6 def initialize(hash) @id = hash[:id] @title = hash[:title] @fail_msg = hash[:fail_msg] @errors = hash[:errors] @result = :skip end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
4 5 6 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 4 def errors @errors end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 4 def id @id end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
4 5 6 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 4 def result @result end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 4 def title @title end |
Instance Method Details
#fail! ⇒ Object
19 20 21 22 23 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 19 def fail! raise 'Cannot fail a check that expects fail message data, use fail_with! method instead' if @fail_msg.respond_to?(:call) && @fail_msg_data.empty? @result = :fail self end |
#fail_msg ⇒ Object
42 43 44 45 46 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 42 def fail_msg return unless failed? return @fail_msg.call(@fail_msg_data) if @fail_msg.respond_to?(:call) && @fail_msg_data @fail_msg end |
#fail_with!(fail_data) ⇒ Object
14 15 16 17 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 14 def fail_with!(fail_data) @fail_msg_data = fail_data fail! end |
#failed? ⇒ Boolean
30 31 32 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 30 def failed? @result == :fail end |
#pass! ⇒ Object
25 26 27 28 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 25 def pass! @result = :pass self end |
#passed? ⇒ Boolean
34 35 36 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 34 def passed? @result == :pass end |
#skipped? ⇒ Boolean
38 39 40 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 38 def skipped? @result == :skip end |
#to_h ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'app/services/foreman_openscap/oval/setup_check.rb', line 48 def to_h { :title => @title, :result => @result, :fail_message => failed? ? fail_msg : nil, :errors => @errors } end |