class Bifrossht::HostFilter

Attributes

filters[R]

Public Class Methods

apply(target) click to toggle source
# File lib/bifrossht/host_filter.rb, line 20
def apply(target)
  filters.each do |filter|
    next unless filter.match(target.host)

    new_host = filter.apply(target.host)
    target.rewrite(new_host)
  end
end
register_filter(config) click to toggle source
# File lib/bifrossht/host_filter.rb, line 13
def register_filter(config)
  @filters ||= []

  klass = build_class_name(config.type)
  @filters << klass.new(config)
end
register_filters(filters = []) click to toggle source
# File lib/bifrossht/host_filter.rb, line 9
def register_filters(filters = [])
  filters.each { |f| register_filter(f) }
end

Private Class Methods

build_class_name(type) click to toggle source
# File lib/bifrossht/host_filter.rb, line 31
def build_class_name(type)
  Object.const_get("Bifrossht::HostFilter::#{type}")
rescue NameError => e
  raise ParameterError, "Cant load host_filter: #{e.message}"
end