Class: ForemanDatacenter::Manufacturer
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ForemanDatacenter::Manufacturer
- Includes:
- Authorizable, ScopedSearchExtensions
- Defined in:
- app/models/foreman_datacenter/manufacturer.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.for_host(host) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/foreman_datacenter/manufacturer.rb', line 25 def self.for_host(host) fact = host.fact_value_by_name('manufacturer') if fact manufacturer = find_by(name: fact.value) if manufacturer manufacturer else create(name: fact.value) end end end |
Instance Method Details
#device_types_count ⇒ Object
15 16 17 |
# File 'app/models/foreman_datacenter/manufacturer.rb', line 15 def device_types_count @device_types_count ||= device_types.count end |
#devices_count ⇒ Object
19 20 21 22 23 |
# File 'app/models/foreman_datacenter/manufacturer.rb', line 19 def devices_count @devices_count ||= self.class.where(id: id). joins(device_types: :devices). count end |