Class: Bifrossht::HostFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/bifrossht/host_filter.rb,
lib/bifrossht/host_filter/base.rb,
lib/bifrossht/host_filter/search_domain.rb

Defined Under Namespace

Classes: Base, SearchDomain

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.filtersObject (readonly)

Returns the value of attribute filters


7
8
9
# File 'lib/bifrossht/host_filter.rb', line 7

def filters
  @filters
end

Class Method Details

.apply(target) ⇒ Object


20
21
22
23
24
25
26
27
# 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) ⇒ Object


13
14
15
16
17
18
# 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 = []) ⇒ Object


9
10
11
# File 'lib/bifrossht/host_filter.rb', line 9

def register_filters(filters = [])
  filters.each { |f| register_filter(f) }
end