Class: ActiveGroonga::Generators::Column
- Inherits:
-
Object
- Object
- ActiveGroonga::Generators::Column
- Defined in:
- lib/rails/generators/active_groonga/migration/column.rb
Overview
:nodoc:
Instance Attribute Summary (collapse)
-
- (Object) name
Returns the value of attribute name.
-
- (Object) options
Returns the value of attribute options.
-
- (Object) type
Returns the value of attribute type.
Instance Method Summary (collapse)
- - (Object) create_code
- - (Boolean) index?
-
- (Column) initialize(name, type, options)
constructor
A new instance of Column.
- - (Boolean) reference?
- - (Object) reference_table_name
- - (Object) remove_code
- - (Boolean) vector?
- - (Boolean) with_position?
- - (Boolean) with_section?
- - (Boolean) with_weight?
Constructor Details
- (Column) initialize(name, type, options)
Returns a new instance of Column
21 22 23 24 25 26 27 28 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 21 def initialize(name, type, ) if type.blank? = "Missing type for attribute '#{name}'.\n" + "Example: '#{name}:short_text' where ShortText is the type." raise Thor::Error, end @name, @type, @options = name, type.to_sym, end |
Instance Attribute Details
- (Object) name
Returns the value of attribute name
19 20 21 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 19 def name @name end |
- (Object) options
Returns the value of attribute options
19 20 21 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 19 def @options end |
- (Object) type
Returns the value of attribute type
19 20 21 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 19 def type @type end |
Instance Method Details
- (Object) create_code
30 31 32 33 34 35 36 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 30 def create_code if index? create_code_index else create_code_normal end end |
- (Boolean) index?
62 63 64 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 62 def index? @type == :index end |
- (Boolean) reference?
66 67 68 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 66 def reference? @type == :reference end |
- (Object) reference_table_name
70 71 72 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 70 def reference_table_name @name.pluralize end |
- (Object) remove_code
38 39 40 41 42 43 44 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 38 def remove_code if index? "remove_index(\"#{name}\")" else "remove_column(:#{name})" end end |
- (Boolean) vector?
46 47 48 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 46 def vector? @options.include?("vector") end |
- (Boolean) with_position?
58 59 60 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 58 def with_position? @options.include?("with_position") end |
- (Boolean) with_section?
50 51 52 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 50 def with_section? @options.include?("with_section") end |
- (Boolean) with_weight?
54 55 56 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 54 def with_weight? @options.include?("with_weight") end |