Class: Groonga::Schema::ColumnRemoveDefinition

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(name, options = {}) ⇒ ColumnRemoveDefinition

Returns a new instance of ColumnRemoveDefinition.



1818
1819
1820
1821
1822
# File 'lib/groonga/schema.rb', line 1818

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

Instance Attribute Details

#nameObject

Returns the value of attribute name.



1815
1816
1817
# File 'lib/groonga/schema.rb', line 1815

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



1816
1817
1818
# File 'lib/groonga/schema.rb', line 1816

def options
  @options
end

Instance Method Details

#define(table_definition, table) ⇒ Object



1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
# File 'lib/groonga/schema.rb', line 1824

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

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

  result = column.remove
  columns_dir = columns_directory_path(table)
  rmdir_if_available(columns_dir)
  result
end