Class: GroongaSchema::Column
- Inherits:
-
Object
- Object
- GroongaSchema::Column
- Defined in:
- lib/groonga-schema/column.rb
Defined Under Namespace
Classes: CommandApplier
Instance Attribute Summary collapse
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#reference_value_type ⇒ Object
writeonly
Sets the attribute reference_value_type.
-
#related_columns ⇒ Object
Returns the value of attribute related_columns.
-
#sources ⇒ Object
Returns the value of attribute sources.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value_type ⇒ Object
Returns the value of attribute value_type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #apply_column(column) ⇒ Object
- #apply_command(command) ⇒ Object
-
#initialize(table_name, name) ⇒ Column
constructor
A new instance of Column.
- #reference_value_type? ⇒ Boolean
- #to_copy_groonga_command(to_table_name, to_name) ⇒ Object
- #to_create_groonga_command ⇒ Object
- #to_migrate_finish_groonga_commands ⇒ Object
- #to_migrate_start_groonga_commands ⇒ Object
- #to_remove_groonga_command ⇒ Object
Constructor Details
#initialize(table_name, name) ⇒ Column
Returns a new instance of Column.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/groonga-schema/column.rb', line 27 def initialize(table_name, name) @table_name = table_name @name = name @type = :scalar @flags = [] @value_type = "ShortText" @sources = [] @reference_value_type = false @related_columns = [] end |
Instance Attribute Details
#flags ⇒ Object
Returns the value of attribute flags.
22 23 24 |
# File 'lib/groonga-schema/column.rb', line 22 def flags @flags end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/groonga-schema/column.rb', line 20 def name @name end |
#reference_value_type=(value) ⇒ Object (writeonly)
Sets the attribute reference_value_type
25 26 27 |
# File 'lib/groonga-schema/column.rb', line 25 def reference_value_type=(value) @reference_value_type = value end |
#related_columns ⇒ Object
Returns the value of attribute related_columns.
26 27 28 |
# File 'lib/groonga-schema/column.rb', line 26 def @related_columns end |
#sources ⇒ Object
Returns the value of attribute sources.
24 25 26 |
# File 'lib/groonga-schema/column.rb', line 24 def sources @sources end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
19 20 21 |
# File 'lib/groonga-schema/column.rb', line 19 def table_name @table_name end |
#type ⇒ Object
Returns the value of attribute type.
21 22 23 |
# File 'lib/groonga-schema/column.rb', line 21 def type @type end |
#value_type ⇒ Object
Returns the value of attribute value_type.
23 24 25 |
# File 'lib/groonga-schema/column.rb', line 23 def value_type @value_type end |
Instance Method Details
#==(other) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/groonga-schema/column.rb', line 55 def ==(other) return false unless other.is_a?(self.class) @table_name == other.table_name and @name == other.name and @type == other.type and @flags.sort == other.flags.sort and @value_type == other.value_type and @sources == other.sources end |
#apply_column(column) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/groonga-schema/column.rb', line 47 def apply_column(column) self.type = column.type self.flags = column.flags self.value_type = column.value_type self.sources = column.sources self.reference_value_type = column.reference_value_type? end |
#apply_command(command) ⇒ Object
42 43 44 45 |
# File 'lib/groonga-schema/column.rb', line 42 def apply_command(command) applier = CommandApplier.new(self, command) applier.apply end |
#reference_value_type? ⇒ Boolean
38 39 40 |
# File 'lib/groonga-schema/column.rb', line 38 def reference_value_type? @reference_value_type end |
#to_copy_groonga_command(to_table_name, to_name) ⇒ Object
74 75 76 |
# File 'lib/groonga-schema/column.rb', line 74 def to_copy_groonga_command(to_table_name, to_name) column_copy_command(to_table_name, to_name) end |
#to_create_groonga_command ⇒ Object
66 67 68 |
# File 'lib/groonga-schema/column.rb', line 66 def to_create_groonga_command column_create_command(@name) end |
#to_migrate_finish_groonga_commands ⇒ Object
89 90 91 92 93 |
# File 'lib/groonga-schema/column.rb', line 89 def to_migrate_finish_groonga_commands [ column_remove_command(old_name), ] end |
#to_migrate_start_groonga_commands ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/groonga-schema/column.rb', line 78 def to_migrate_start_groonga_commands commands = [] commands << column_create_command(new_name) if type != :index commands << column_copy_command(@table_name, new_name) end commands << column_rename_command(@name, old_name) commands << column_rename_command(new_name, @name) commands end |
#to_remove_groonga_command ⇒ Object
70 71 72 |
# File 'lib/groonga-schema/column.rb', line 70 def to_remove_groonga_command column_remove_command(@name) end |