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.



1550
1551
1552
1553
1554
# File 'lib/groonga/schema.rb', line 1550

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.



1547
1548
1549
# File 'lib/groonga/schema.rb', line 1547

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



1548
1549
1550
# File 'lib/groonga/schema.rb', line 1548

def options
  @options
end

Instance Method Details

#define(table_definition, table) ⇒ Object



1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
# File 'lib/groonga/schema.rb', line 1556

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