Class: DbAgent::TableOrderer
- Inherits:
-
Object
- Object
- DbAgent::TableOrderer
show all
- Defined in:
- lib/db_agent/table_orderer.rb
Defined Under Namespace
Classes: TSortComputation
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
5
6
7
|
# File 'lib/db_agent/table_orderer.rb', line 5
def initialize(handler)
@handler = handler
end
|
Instance Attribute Details
#handler ⇒ Object
Returns the value of attribute handler.
8
9
10
|
# File 'lib/db_agent/table_orderer.rb', line 8
def handler
@handler
end
|
Instance Method Details
#db ⇒ Object
10
11
12
|
# File 'lib/db_agent/table_orderer.rb', line 10
def db
handler.sequel_db
end
|
#dependencies(table) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/db_agent/table_orderer.rb', line 22
def dependencies(table)
_dependencies(table, ds = {})
ds
.inject([]){|memo,(_,plus)| (memo + plus).uniq }
.sort{|t1,t2| tsort.index(t1) - tsort.index(t2) }
.reject{|x| x == table }
end
|
#graph ⇒ Object
18
19
20
|
# File 'lib/db_agent/table_orderer.rb', line 18
def graph
@graph ||= TSortComputation.new(db).graph
end
|
#tsort ⇒ Object
14
15
16
|
# File 'lib/db_agent/table_orderer.rb', line 14
def tsort
@tsort ||= TSortComputation.new(db).to_a
end
|