Sha256: 6b8b55ab1d6789b8bdd7fec1f8dfa8476dbd1680d8b9c4b157d8825ddfc34b10

Contents?: true

Size: 537 Bytes

Versions: 9

Compression:

Stored size: 537 Bytes

Contents

module ForemanOpenscap
  class Asset < ApplicationRecord
    has_many :asset_policies, :dependent => :delete_all
    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

9 entries across 9 versions & 1 rubygems

Version Path
foreman_openscap-10.0.3 app/models/foreman_openscap/asset.rb
foreman_openscap-10.0.2 app/models/foreman_openscap/asset.rb
foreman_openscap-10.0.1 app/models/foreman_openscap/asset.rb
foreman_openscap-10.0.0 app/models/foreman_openscap/asset.rb
foreman_openscap-9.0.4 app/models/foreman_openscap/asset.rb
foreman_openscap-9.0.3 app/models/foreman_openscap/asset.rb
foreman_openscap-9.0.2 app/models/foreman_openscap/asset.rb
foreman_openscap-9.0.1 app/models/foreman_openscap/asset.rb
foreman_openscap-9.0.0 app/models/foreman_openscap/asset.rb