Sha256: 15241681ea6c99d359de6795e5ee92a9a6b11c356ac19de6f30a4135b76a95c2

Contents?: true

Size: 630 Bytes

Versions: 1

Compression:

Stored size: 630 Bytes

Contents

module Cmap; class SubqueryExpander

  attr_reader :table_name, :schema_name, :subquery_gsubs

  def initialize(args)
    @table_name = args.fetch(:table_name)
    @schema_name = args.fetch(:schema_name)
    @subquery_gsubs = args.fetch(:subquery_gsubs, [])
  end

  def update_query?(edge)
    edge.value != query(edge)
  end

  def query(edge)
    r = edge.value
    replacements = [["+table_name+", table_name], ["+schema_name+", schema_name], ["+destination_vertex+", edge.destination_vertex], ["+origin_vertex+", edge.origin_vertex]]
    (subquery_gsubs + replacements).each {|gsub| r = r.gsub(*gsub)}
    r
  end

end; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cmap-0.4.0 lib/cmap/subquery_expander.rb