Sha256: 4b8627cd649d17a925242da168f8b10a34f5af85681043bd55feb8244861ef24

Contents?: true

Size: 941 Bytes

Versions: 5

Compression:

Stored size: 941 Bytes

Contents

module ForemanOpenscap
  module Oval
    class SetupCheck
      attr_reader :result, :id

      def initialize(hash)
        @id = hash[:id]
        @title = hash[:title]
        @fail_msg = hash[:fail_msg]
        @errors = hash[:errors]
        @result = :skip
      end

      def fail_with!(fail_data)
        @fail_msg_data = fail_data
        fail!
      end

      def fail!
        @result = :fail
        self
      end

      def pass!
        @result = :pass
        self
      end

      def failed?
        @result == :fail
      end

      def passed?
        @result == :pass
      end

      def skipped?
        @result == :skip
      end

      def fail_msg
        @fail_msg.call @fail_msg_data if @fail_msg
      end

      def to_h
        {
          :title => @title,
          :result => @result,
          :fail_message => failed? ? fail_msg : nil,
          :errors => @errors
        }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_openscap-5.0.0 app/services/foreman_openscap/oval/setup_check.rb
foreman_openscap-4.3.3 app/services/foreman_openscap/oval/setup_check.rb
foreman_openscap-4.3.2 app/services/foreman_openscap/oval/setup_check.rb
foreman_openscap-4.3.1 app/services/foreman_openscap/oval/setup_check.rb
foreman_openscap-4.3.0 app/services/foreman_openscap/oval/setup_check.rb