Class: Cmap::SubqueryExpander

Inherits:
Object
  • Object
show all
Defined in:
lib/cmap/subquery_expander.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ SubqueryExpander

Returns a new instance of SubqueryExpander.



5
6
7
8
9
# File 'lib/cmap/subquery_expander.rb', line 5

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

Instance Attribute Details

#schema_nameObject (readonly)

Returns the value of attribute schema_name.



3
4
5
# File 'lib/cmap/subquery_expander.rb', line 3

def schema_name
  @schema_name
end

#subquery_gsubsObject (readonly)

Returns the value of attribute subquery_gsubs.



3
4
5
# File 'lib/cmap/subquery_expander.rb', line 3

def subquery_gsubs
  @subquery_gsubs
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



3
4
5
# File 'lib/cmap/subquery_expander.rb', line 3

def table_name
  @table_name
end

Instance Method Details

#query(edge) ⇒ Object



15
16
17
18
19
20
# File 'lib/cmap/subquery_expander.rb', line 15

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

#update_query?(edge) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/cmap/subquery_expander.rb', line 11

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