Class: ForemanDatacenter::DeviceRole
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ForemanDatacenter::DeviceRole
- Includes:
- Authorizable, ScopedSearchExtensions
- Defined in:
- app/models/foreman_datacenter/device_role.rb
Constant Summary collapse
- COLORS =
[ 'Teal', 'Green', 'Blue', 'Purple', 'Yellow', 'Orange', 'Red', 'Light Gray', 'Medium Gray', 'Dark Gray' ].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.for_host ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/models/foreman_datacenter/device_role.rb', line 28 def self.for_host role = find_by_name('Server') if role role else create!(name: 'Server', color: 'Green') end end |
Instance Method Details
#devices_count ⇒ Object
22 23 24 25 26 |
# File 'app/models/foreman_datacenter/device_role.rb', line 22 def devices_count @devices_count ||= self.class.where(id: id). joins(:devices). count end |