require_relative '../visitors/configuration_visitor' class ConfigurationPageFacade @configurations_hash="" def self.AssemblePage @configurations_hash = ConfigurationVisitor.Visit final_html = self.Title final_html += self.ConfigurationsForm return final_html end def self.Title return "

Configurations Page

\n" end def self.ConfigurationsForm final_html = "
\n" @configurations_hash.each do |rule, configurations| final_html += self.RuleConfigurations(rule,configurations) end final_html += "\n" final_html += "
\n" return final_html end def self.RuleConfigurations(rule,configurations) final_html = "

#{rule.name}

\n" configurations.each do |configuration| final_html += self.Input(configuration) end return final_html end def self.Input(configuration) return_value = "\n" case configuration.displayfield when DisplayField[:CheckBox] return_value += "
\n" when DisplayField[:SelectBox] return_value += "
" end return_value += "

#{configuration.description}

\n
\n" return return_value end def self.ApplyConfigurations(new_conf) @configurations_hash.each do |rule, configurations| configurations.each do |configuration| case configuration.displayfield when DisplayField[:CheckBox] if new_conf.has_key?(configuration.id) configuration.value = true else configuration.value = false end when DisplayField[:SelectBox] configuration.value = new_conf[configuration.id].split(/\r?\n/).delete_if(&:empty?) else configuration.value = new_conf[configuration.id] end end end end private_class_method :Title,:ConfigurationsForm, :RuleConfigurations, :Input end