class FakePipe::Postgres::CommentBlock

Finds Postgres comment DML.

Public Instance Methods

on_start_text(match, line) click to toggle source
# File lib/fake_pipe/postgres/comment_block.rb, line 11
def on_start_text(match, line)
  self.table = match[:table]
  parse_config(match)
end
parse(*) click to toggle source
# File lib/fake_pipe/postgres/comment_block.rb, line 29
def parse(*)
  raise '`parse` should not be called to extract config from comments. ' \
       ' Try inspecting the PG dump format for changes. Comments are normally all in a single line.'
end
parse_config(match) click to toggle source
# File lib/fake_pipe/postgres/comment_block.rb, line 16
def parse_config(match)
  # consolidate escaped single quotes
  comment = match[:comment].gsub("''", "'")
  data = YAML.load(comment).with_indifferent_access

  # give the config back to the delegate
  delegate.on_config(
    table: match[:table],
    column: match[:column],
    config: data[:anon]
  )
end