class Stacco::Domain

Attributes

logical_name[RW]
service_registry[RW]

Public Class Methods

new(stack, domain_parts) click to toggle source
# File lib/stacco/domain.rb, line 6
def initialize(stack, domain_parts)
  @stack = stack
  @domain_parts = domain_parts
end

Public Instance Methods

+(domain_part) click to toggle source
# File lib/stacco/domain.rb, line 22
def +(domain_part)
  subdomain = self.class.new(@stack, @domain_parts + [domain_part])
  subdomain.service_registry = @service_registry
  subdomain
end
find_resource_with_matching(in_collection) { |r| ... } click to toggle source
# File lib/stacco/domain.rb, line 28
def find_resource_with_matching(in_collection)
  possible_zone_keys = (1..@domain_parts.length).map{ |l| @domain_parts[0, l].reverse.join('.') }.reverse
  possible_zone_keys.each do |zone_key|
    if matching_resource = in_collection.find{ |r| yield(r) == zone_key }
      return matching_resource
    end
  end

  nil
end
hosted_zone() click to toggle source
# File lib/stacco/domain.rb, line 39
def hosted_zone
  self.find_resource_with_matching(@service_registry[:route53].hosted_zones){ |zone| zone.name.gsub(/\.$/, '') }
end
server_certificate() click to toggle source
# File lib/stacco/domain.rb, line 43
def server_certificate
  self.find_resource_with_matching(@service_registry[:iam].server_certificates){ |cert| cert.name }
end
to_json() click to toggle source
# File lib/stacco/domain.rb, line 18
def to_json
  self.to_s.to_json
end
to_s() click to toggle source
# File lib/stacco/domain.rb, line 14
def to_s
  @domain_parts.reverse.join('.')
end