Class: Bricolage::StreamingLoad::ChunkRouter::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/bricolage/streamingload/chunkrouter.rb

Instance Method Summary collapse

Constructor Details

#initialize(url:, schema:, table:) ⇒ Route

Returns a new instance of Route.



31
32
33
34
35
# File 'lib/bricolage/streamingload/chunkrouter.rb', line 31

def initialize(url:, schema:, table:)
  @url_pattern = /\A#{url}\z/
  @schema = schema
  @table = table
end

Instance Method Details

#get_component(m, label) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/bricolage/streamingload/chunkrouter.rb', line 44

def get_component(m, label)
  if /\A%/ =~ label
    m[label[1..-1]]
  else
    label
  end
end

#match(url) ⇒ Object



37
38
39
40
41
42
# File 'lib/bricolage/streamingload/chunkrouter.rb', line 37

def match(url)
  m = @url_pattern.match(url) or return nil
  c1 = get_component(m, @schema)
  c2 = get_component(m, @table)
  "#{c1}.#{c2}"
end