Project

General

Profile

Download (747 Bytes) Statistics
| Branch: | Tag: | Revision:
module PuppetclassTotalHosts
module Indirect
extend ActiveSupport::Concern

included do
#updates counters for all puppetclasses affected indirectly
def update_puppetclasses_total_hosts(relation = nil)
if self.is_a?(Hostgroup)
config_groups.each(&:update_puppetclasses_total_hosts) if config_groups.present?
parent.update_puppetclasses_total_hosts unless is_root?
end
puppetclasses.each(&:update_total_hosts) if puppetclasses.present?
end
end
end

module JoinTable
extend ActiveSupport::Concern

included do
after_save :update_total_hosts
after_destroy :update_total_hosts

delegate :update_total_hosts, :to => :puppetclass
end
end
end
(17-17/23)