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

Version Path
odania-0.1.0 lib/odania/config/domain.rb
odania-0.0.39 lib/odania/config/domain.rb
odania-0.0.38 lib/odania/config/domain.rb
odania-0.0.37 lib/odania/config/domain.rb
odania-0.0.36 lib/odania/config/domain.rb
odania-0.0.35 lib/odania/config/domain.rb
odania-0.0.34 lib/odania/config/domain.rb
odania-0.0.33 lib/odania/config/domain.rb
odania-0.0.32 lib/odania/config/domain.rb
odania-0.0.31 lib/odania/config/domain.rb
odania-0.0.30 lib/odania/config/domain.rb
odania-0.0.29 lib/odania/config/domain.rb
odania-0.0.28 lib/odania/config/domain.rb
odania-0.0.27 lib/odania/config/domain.rb
odania-0.0.26 lib/odania/config/domain.rb
odania-0.0.25 lib/odania/config/domain.rb
odania-0.0.24 lib/odania/config/domain.rb
odania-0.0.23 lib/odania/config/domain.rb
odania-0.0.22 lib/odania/config/domain.rb
odania-0.0.21 lib/odania/config/domain.rb