Sha256: 9a0c5949d66686a992e0ed153bc0cbd4c996485f99e5302df501301e7d9b5733

Contents?: true

Size: 617 Bytes

Versions: 4

Compression:

Stored size: 617 Bytes

Contents

require 'taketo/node_resolver'
require 'taketo/constructs/server'

module Taketo

  class ServerResolver < NodeResolver
    def nodes
      super.select { |n| Taketo::Constructs::Server === n }
    end
    alias :servers :nodes

    def resolve
      resolve_by_global_alias || resolve_by_path
    end

    def resolve_by_global_alias
      unless @path.to_s.empty?
        servers.select(&:global_alias).detect { |s| s.global_alias == @path.to_s }
      end
    end

    def resolve_by_path
      matching_servers = servers.select { |s| s.path =~ /^#@path/ }
      disambiguate(matching_servers)
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
taketo-0.3.1 lib/taketo/server_resolver.rb
taketo-0.3.0 lib/taketo/server_resolver.rb
taketo-0.2.0 lib/taketo/server_resolver.rb
taketo-0.2.0.alpha lib/taketo/server_resolver.rb