Sha256: 7edac8df71871d3a82c17630bcb6280e96b55978d2afcb82662b1459d99d7bcd
Contents?: true
Size: 1.13 KB
Versions: 23
Compression:
Stored size: 1.13 KB
Contents
module Odania module Config class Domain attr_accessor :name, :subdomains, :config, :redirects def initialize(name) self.name = name reset end def add_subdomain(subdomain_name) self.subdomains[subdomain_name] end def subdomain(name) self.subdomains[name] end def dump subdomain_data = {} subdomains.each_pair do |name, subdomain| subdomain_data[name] = subdomain.dump end subdomain_data end def load(data) self.name = data['name'] unless data['name'].nil? self.add(data) end def add(sub_domain_data, group_name=nil) duplicates = Hash.new { |hash, key| hash[key] = [] } unless sub_domain_data.nil? sub_domain_data.each_pair do |name, data| subdomain_duplicates = self.subdomains[name].add(data, group_name) duplicates.deep_merge! subdomain_duplicates end end duplicates end def get_redirects self.subdomains['_general'].get_redirects end def [](key) self.subdomains[key] end private def reset self.subdomains = Hash.new { |hash, key| hash[key] = SubDomain.new(key) } end end end end
Version data entries
23 entries across 23 versions & 1 rubygems