Sha256: 14905a6dd044fa2dc0b77b3707da6a42b862aef66e3735a2c90bb43f3f743335

Contents?: true

Size: 965 Bytes

Versions: 16

Compression:

Stored size: 965 Bytes

Contents

module ForemanOpenscap
  module HostgroupExtensions
    extend ActiveSupport::Concern

    include InheritedPolicies

    included do
      has_one :asset, :as => :assetable, :class_name => "::ForemanOpenscap::Asset", dependent: :destroy
      has_many :asset_policies, :through => :asset, :class_name => "::ForemanOpenscap::AssetPolicy"
      has_many :policies, :through => :asset_policies, :class_name => "::ForemanOpenscap::Policy"
    end

    def inherited_policies
      find_inherited_policies :policies
    end

    def openscap_proxy
      return super if ancestry.nil? || self.openscap_proxy_id.present?
      ::SmartProxy.find_by(:id => inherited_openscap_proxy_id)
    end

    def inherited_openscap_proxy_id
      if ancestry.present?
        self[:openscap_proxy_id] || self.class.sort_by_ancestry(ancestors.where.not(openscap_proxy_id: nil)).last.try(:openscap_proxy_id)
      else
        self.send(:openscap_proxy_id)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
foreman_openscap-8.0.0 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-7.1.1 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-7.1.0 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-7.0.0 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-6.0.0 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-5.2.3 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-5.2.2 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-5.1.1 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-5.2.1 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-5.2.0 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-5.1.0 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-5.0.0 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-4.3.3 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-4.3.2 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-4.3.1 app/models/concerns/foreman_openscap/hostgroup_extensions.rb
foreman_openscap-4.3.0 app/models/concerns/foreman_openscap/hostgroup_extensions.rb