Sha256: cb4bd9ac8d8893c59692b2bceab78b7b5f7b8f2e2f4bb78a709fc2a030c095b9

Contents?: true

Size: 552 Bytes

Versions: 26

Compression:

Stored size: 552 Bytes

Contents

module ForemanOpenscap
  module ScapFileContent
    require 'digest/sha2'

    extend ActiveSupport::Concern

    included do
      validates :digest, :presence => true
      validates :scap_file, :presence => true

      before_validation :redigest, :if => lambda { |file_content| file_content.persisted? && file_content.scap_file_changed? }
    end

    def digest
      self[:digest] ||= Digest::SHA256.hexdigest(scap_file.to_s)
    end

    private

    def redigest
      self[:digest] = Digest::SHA256.hexdigest(scap_file.to_s)
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foreman_openscap-10.1.0 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-10.0.3 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-10.0.2 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-10.0.1 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-10.0.0 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-9.0.4 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-9.0.3 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-9.0.2 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-9.0.1 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-9.0.0 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-8.0.0 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-7.1.1 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-7.1.0 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-7.0.0 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-6.0.0 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-5.2.3 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-5.2.2 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-5.1.1 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-5.2.1 app/models/concerns/foreman_openscap/scap_file_content.rb
foreman_openscap-5.2.0 app/models/concerns/foreman_openscap/scap_file_content.rb