Class: Groonga::Schema::ColumnDefinition
- Inherits:
-
Object
- Object
- Groonga::Schema::ColumnDefinition
- 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.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #define(table_definition, table) ⇒ Object
-
#initialize(name, options = {}) ⇒ ColumnDefinition
constructor
A new instance of ColumnDefinition.
Constructor Details
#initialize(name, options = {}) ⇒ ColumnDefinition
Returns a new instance of ColumnDefinition.
744 745 746 747 748 749 |
# File 'lib/groonga/schema.rb', line 744 def initialize(name, ={}) @name = name @name = @name.to_s if @name.is_a?(Symbol) @options = ( || {}).dup @type = nil end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
741 742 743 |
# File 'lib/groonga/schema.rb', line 741 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
742 743 744 |
# File 'lib/groonga/schema.rb', line 742 def @options end |
#type ⇒ Object
Returns the value of attribute type.
741 742 743 |
# File 'lib/groonga/schema.rb', line 741 def type @type end |
Instance Method Details
#define(table_definition, table) ⇒ Object
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 |
# File 'lib/groonga/schema.rb', line 751 def define(table_definition, table) column = table.column(@name) if column return column if same_column?(table_definition, column) if @options.delete(:force) column.remove else raise ArgumentError, "the same name column with different type is " + "already defined: #{@type.inspect}(#{@options.inspect}): " + "#{column.inspect}" end end table.define_column(@name, Schema.normalize_type(@type), @options) end |