Class: Droonga::Catalog::Schema::ColumnCreateSorter

Inherits:
Object
  • Object
show all
Includes:
TSort
Defined in:
lib/droonga/catalog/schema.rb

Instance Method Summary collapse

Constructor Details

#initialize(tables) ⇒ ColumnCreateSorter

Returns a new instance of ColumnCreateSorter.



211
212
213
# File 'lib/droonga/catalog/schema.rb', line 211

def initialize(tables)
  @tables = tables
end

Instance Method Details

#all_columnsObject



215
216
217
# File 'lib/droonga/catalog/schema.rb', line 215

def all_columns
  @tables.values.collect {|table| table.columns.values}.flatten
end

#tsort_each_child(column, &block) ⇒ Object



223
224
225
226
227
228
229
230
231
232
# File 'lib/droonga/catalog/schema.rb', line 223

def tsort_each_child(column, &block)
  dependent_column_names = column.index_options.sources || []
  dependent_column_names -= ["_key"] # _key always exists after the table created
  reference_table = @tables[column.value_type_groonga]
  # TODO when _key specified, check to ensure reference_table is not Array
  dependent_columns = dependent_column_names.collect do |column_name|
    reference_table.columns[column_name]
  end
  dependent_columns.each(&block)
end

#tsort_each_node(&block) ⇒ Object



219
220
221
# File 'lib/droonga/catalog/schema.rb', line 219

def tsort_each_node(&block)
  all_columns.each(&block)
end