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.



1533
1534
1535
1536
1537
# File 'lib/groonga/schema.rb', line 1533

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.



1530
1531
1532
# File 'lib/groonga/schema.rb', line 1530

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



1531
1532
1533
# File 'lib/groonga/schema.rb', line 1531

def options
  @options
end

Instance Method Details

#define(table_definition, table) ⇒ Object



1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
# File 'lib/groonga/schema.rb', line 1539

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