Sha256: d8ca465026b502d1f6c83abd0e85b1aacf1aab798effc81c11175254c19a7cff

Contents?: true

Size: 500 Bytes

Versions: 3

Compression:

Stored size: 500 Bytes

Contents

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

    scope :hosts, 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

3 entries across 3 versions & 1 rubygems

Version Path
foreman_openscap-0.5.2 app/models/foreman_openscap/asset.rb
foreman_openscap-0.5.1 app/models/foreman_openscap/asset.rb
foreman_openscap-0.5.0 app/models/foreman_openscap/asset.rb