class Roda::RodaPlugins::HostRouting::DSL
def default(hostname, &block)
provided to +to+. If the block returns nil/false, the hostname
called with the host if there is no match for one of the hostnames
Register the default hostname. If a block is provided, it is
def default(hostname, &block) @default_host = hostname @default_block = block end
def initialize
def initialize @hosts = [] @host_hash = {} end
def process(&block)
def process(&block) instance_exec(self, &block) if !@default_host raise RodaError, "must call default method inside host_routing plugin block to set default host" end @hosts.concat(@host_hash.values) @hosts << @default_host @hosts.uniq! [@hosts.freeze, @host_hash.freeze, @default_block, @default_host].freeze end
def register(*hosts)
calling register with a block, where the block can return
Register hosts that can be returned. This is only needed if
def register(*hosts) @hosts = hosts end
def to(host, *hostnames)
def to(host, *hostnames) hostnames.each do |hostname| @host_hash[hostname] = host end end