Sha256: 42f297070069ffd72caca71424f160f13b6d4a5856a9771e71178bc95435f4a7

Contents?: true

Size: 782 Bytes

Versions: 5

Compression:

Stored size: 782 Bytes

Contents

module ForemanOpenscap
  class OvalContent < ApplicationRecord
    audited :except => [:scap_file]
    include Authorizable
    include Taxonomix
    include ScapFileContent

    scoped_search :on => :name, :complete_value => true

    has_many :oval_policies
    validates :name, :presence => true, :length => { :maximum => 255 }, uniqueness: true
    validates :url, :format => { :with => %r{\Ahttps?://} }, :allow_blank => true

    before_validation :fetch_remote_content, :if => lambda { |oval_content| oval_content.url.present? }

    def to_h
      { :id => id, :name => name, :original_filename => original_filename, :changed_at => changed_at }
    end

    private

    def fetch_remote_content
      ForemanOpenscap::Oval::SyncOvalContents.new.sync self
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_openscap-5.0.0 app/models/foreman_openscap/oval_content.rb
foreman_openscap-4.3.3 app/models/foreman_openscap/oval_content.rb
foreman_openscap-4.3.2 app/models/foreman_openscap/oval_content.rb
foreman_openscap-4.3.1 app/models/foreman_openscap/oval_content.rb
foreman_openscap-4.3.0 app/models/foreman_openscap/oval_content.rb