class GroongaSchema::Schema
Attributes
columns[R]
plugins[R]
tables[R]
Public Class Methods
new()
click to toggle source
# File lib/groonga-schema/schema.rb, line 26 def initialize @plugins = [] @tables = {} @columns = {} end
Public Instance Methods
apply_command(command)
click to toggle source
# File lib/groonga-schema/schema.rb, line 32 def apply_command(command) case command.command_name when "register" plugin = Plugin.new(command.path) @plugins << plugin when "plugin_register" plugin = Plugin.new(command.name) @plugins << plugin when "table_create" apply_command_table_create(command) when "column_create" apply_command_column_create(command) end end
Private Instance Methods
apply_command_column_create(command)
click to toggle source
# File lib/groonga-schema/schema.rb, line 60 def apply_command_column_create(command) column = Column.new(command.table, command.name) column.apply_command(command) table = @tables[column.table_name] if table table.columns << column end refered_table = @tables[column.value_type] if refered_table column.reference_value_type = true refered_table.related_columns << column refered_columns = @columns[column.value_type] || {} column.sources.each do |source| next if source == "_key" source_column = refered_columns[source] if source_column source_column.related_columns << column end end end @columns[column.table_name] ||= {} @columns[column.table_name][column.name] = column end
apply_command_table_create(command)
click to toggle source
# File lib/groonga-schema/schema.rb, line 48 def apply_command_table_create(command) table = Table.new(command.name) table.apply_command(command) refered_table = @tables[table.key_type] if refered_table table.reference_key_type = true refered_table.related_tables << table end @tables[table.name] = table @columns[table.name] ||= {} end