Sha256: 91890d5a7f782237e9e9c8a47fe519327736d27d9ab03fd846cd5fbea824288d

Contents?: true

Size: 511 Bytes

Versions: 23

Compression:

Stored size: 511 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, 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

23 entries across 23 versions & 1 rubygems

Version Path
foreman_openscap-0.7.13 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.12 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.11 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.10 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.9 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.8 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.7 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.6 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.5 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.4 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.2 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.1 app/models/foreman_openscap/asset.rb
foreman_openscap-0.6.7 app/models/foreman_openscap/asset.rb
foreman_openscap-0.7.0 app/models/foreman_openscap/asset.rb
foreman_openscap-0.6.6 app/models/foreman_openscap/asset.rb
foreman_openscap-0.6.5 app/models/foreman_openscap/asset.rb
foreman_openscap-0.6.4 app/models/foreman_openscap/asset.rb
foreman_openscap-0.6.3 app/models/foreman_openscap/asset.rb
foreman_openscap-0.6.2 app/models/foreman_openscap/asset.rb
foreman_openscap-0.6.1 app/models/foreman_openscap/asset.rb