Class: ForemanTrend

Inherits:
Trend
  • Object
show all
Defined in:
app/models/foreman_trend.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Trend

#to_param

Class Method Details

.create_values(trendable_type) ⇒ Object


17
18
19
# File 'app/models/foreman_trend.rb', line 17

def self.create_values(trendable_type)
  trendable_type.constantize.all.map { |t| t.trends.create(:fact_value => t.to_label)}
end

.model_nameObject


31
32
33
# File 'app/models/foreman_trend.rb', line 31

def self.model_name
  Trend.model_name
end

Instance Method Details

#create_valuesObject


13
14
15
# File 'app/models/foreman_trend.rb', line 13

def create_values
  self.class.create_values(self.trendable_type)
end

#destroy_valuesObject


21
22
23
24
# File 'app/models/foreman_trend.rb', line 21

def destroy_values
  ids = ForemanTrend.where(:trendable_type => trendable_type).pluck(:id)
  super(ids)
end

#find_hostsObject


35
36
37
# File 'app/models/foreman_trend.rb', line 35

def find_hosts
  trendable.hosts.find(:all, :order => 'name')
end

#to_labelObject


5
6
7
# File 'app/models/foreman_trend.rb', line 5

def to_label
  trendable ? trendable.to_label : trendable_type
end

#type_nameObject


9
10
11
# File 'app/models/foreman_trend.rb', line 9

def type_name
  trendable_type
end

#valuesObject


26
27
28
29
# File 'app/models/foreman_trend.rb', line 26

def values
  return ForemanTrend.where(:id => self) if fact_value
  ForemanTrend.has_value.where(:trendable_type => trendable_type)
end