Sha256: c0e10ac17f7adba973ad0e91de4eb4a5f2df1bfe1cd71c43b29022f583391b7d

Contents?: true

Size: 510 Bytes

Versions: 71

Compression:

Stored size: 510 Bytes

Contents

module ForemanOpenscap
  class Asset < ApplicationRecord
    has_many :asset_policies
    has_many :policies, :through => :asset_policies
    belongs_to :assetable, :polymorphic => true

    scope :hosts, lambda { where(:assetable_type => 'Host::Base') }

    def host
      fetch_asset('Host::Base')
    end

    def hostgroup
      fetch_asset('Hostgroup')
    end

    def name
      assetable.name
    end

    private

    def fetch_asset(type)
      assetable if assetable_type == type
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
foreman_openscap-8.0.0 app/models/foreman_openscap/asset.rb
foreman_openscap-7.1.1 app/models/foreman_openscap/asset.rb
foreman_openscap-7.1.0 app/models/foreman_openscap/asset.rb
foreman_openscap-7.0.0 app/models/foreman_openscap/asset.rb
foreman_openscap-6.0.0 app/models/foreman_openscap/asset.rb
foreman_openscap-5.2.3 app/models/foreman_openscap/asset.rb
foreman_openscap-5.2.2 app/models/foreman_openscap/asset.rb
foreman_openscap-5.1.1 app/models/foreman_openscap/asset.rb
foreman_openscap-5.2.1 app/models/foreman_openscap/asset.rb
foreman_openscap-5.2.0 app/models/foreman_openscap/asset.rb
foreman_openscap-5.1.0 app/models/foreman_openscap/asset.rb
foreman_openscap-5.0.0 app/models/foreman_openscap/asset.rb
foreman_openscap-4.3.3 app/models/foreman_openscap/asset.rb
foreman_openscap-4.3.2 app/models/foreman_openscap/asset.rb
foreman_openscap-4.3.1 app/models/foreman_openscap/asset.rb
foreman_openscap-4.3.0 app/models/foreman_openscap/asset.rb
foreman_openscap-4.1.3 app/models/foreman_openscap/asset.rb
foreman_openscap-4.0.6 app/models/foreman_openscap/asset.rb
foreman_openscap-4.2.0 app/models/foreman_openscap/asset.rb
foreman_openscap-4.0.5 app/models/foreman_openscap/asset.rb