Class: FakePipe::Postgres::CommentBlock
- Defined in:
- lib/fake_pipe/postgres/comment_block.rb
Overview
Finds Postgres comment DML.
Instance Attribute Summary
Attributes inherited from TextBlock
#delegate, #start_match, #table
Instance Method Summary collapse
Methods inherited from TextBlock
#end_text?, #initialize, #match_start_text, #start_text?
Constructor Details
This class inherits a constructor from FakePipe::TextBlock
Instance Method Details
#on_start_text(match, line) ⇒ Object
11 12 13 14 |
# 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 ⇒ Object
29 30 31 32 |
# 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) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# 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 |