Class: Groonga::Schema::IndexColumnDefinition
- Inherits:
-
Object
- Object
- Groonga::Schema::IndexColumnDefinition
- Defined in:
- lib/groonga/schema.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
- #define(table_definition, table) ⇒ Object
-
#initialize(name, options = {}) ⇒ IndexColumnDefinition
constructor
A new instance of IndexColumnDefinition.
Constructor Details
#initialize(name, options = {}) ⇒ IndexColumnDefinition
Returns a new instance of IndexColumnDefinition.
796 797 798 799 800 801 |
# File 'lib/groonga/schema.rb', line 796 def initialize(name, ={}) @name = name @name = @name.to_s if @name.is_a?(Symbol) @options = ( || {}).dup @target = nil end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
793 794 795 |
# File 'lib/groonga/schema.rb', line 793 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
794 795 796 |
# File 'lib/groonga/schema.rb', line 794 def @options end |
#target ⇒ Object
Returns the value of attribute target.
793 794 795 |
# File 'lib/groonga/schema.rb', line 793 def target @target end |
Instance Method Details
#define(table_definition, table) ⇒ Object
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
# File 'lib/groonga/schema.rb', line 803 def define(table_definition, table) target = @target unless target.is_a?(Groonga::Object) target = table_definition.context[target] end if target.nil? raise ArgumentError, "Unknown index target: #{@target.inspect}" end index = table.column(@name) if index return index if same_index?(table_definition, index, target) if @options.delete(:force) index.remove else raise ArgumentError, "the same name index column with " + "different target or options is " + "already defined: #{target.inspect}(#{@options.inspect}): " + "#{index.inspect}" end end index = table.define_index_column(@name, target.table, @options) index.source = target index end |