Class: Groonga::Schema::ColumnRenameDefinition

Inherits:
Object
  • Object
show all
Includes:
Path
Defined in:
lib/groonga/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Path

#columns_directory_path, #rmdir_if_available, #tables_directory_path

Constructor Details

#initialize(current_name, new_name, options = {}) ⇒ ColumnRenameDefinition

Returns a new instance of ColumnRenameDefinition.



1792
1793
1794
1795
1796
1797
1798
# File 'lib/groonga/schema.rb', line 1792

def initialize(current_name, new_name, options={})
  @current_name = current_name
  @current_name = @current_name.to_s if @current_name.is_a?(Symbol)
  @new_name = new_name
  @new_name = @new_name.to_s if @new_name.is_a?(Symbol)
  @options = (options || {}).dup
end

Instance Attribute Details

#current_nameObject

Returns the value of attribute current_name.



1789
1790
1791
# File 'lib/groonga/schema.rb', line 1789

def current_name
  @current_name
end

#new_nameObject

Returns the value of attribute new_name.



1789
1790
1791
# File 'lib/groonga/schema.rb', line 1789

def new_name
  @new_name
end

#optionsObject (readonly)

Returns the value of attribute options.



1790
1791
1792
# File 'lib/groonga/schema.rb', line 1790

def options
  @options
end

Instance Method Details

#define(table_definition, table) ⇒ Object



1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
# File 'lib/groonga/schema.rb', line 1800

def define(table_definition, table)
  if @current_name.respond_to?(:call)
    current_name = @current_name.call(table_definition.context)
  else
    current_name = @current_name
  end
  column = table.column(current_name)

  if column.nil?
    raise ColumnNotExists.new(name)
  end

  column.rename(@new_name)
end