Class: Noah::Services

Inherits:
Object
  • Object
show all
Defined in:
lib/noah/models/services.rb

Class Method Summary collapse

Class Method Details

.all(options = {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/noah/models/services.rb', line 51

def self.all(options = {})
  service_hash = Hash.new
  options.empty? ? services=Service.all.sort : services=Service.find(options).sort
  services.each do |svc|
    service_hash["#{svc.name}"] = Hash.new unless service_hash.has_key?(svc.name)
    host_name = Noah::Host[svc.host_id].name
    service_hash["#{svc.name}"]["#{host_name}"] = Hash.new
    service_hash["#{svc.name}"]["#{host_name}"].merge!({:id => svc.id, :status => svc.status, :tags => svc.to_hash[:tags], :links => svc.to_hash[:links], :created_at => svc.created_at, :updated_at => svc.updated_at})
  end
  service_hash
end