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
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #create_code ⇒ Object
- #index? ⇒ Boolean
-
#initialize(name, type, options) ⇒ Column
constructor
A new instance of Column.
- #reference? ⇒ Boolean
- #reference_table_name ⇒ Object
- #remove_code ⇒ Object
- #vector? ⇒ Boolean
- #with_position? ⇒ Boolean
- #with_section? ⇒ Boolean
- #with_weight? ⇒ Boolean
Constructor Details
#initialize(name, type, options) ⇒ Column
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, = name, type.to_sym, end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
19 20 21 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 19 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
19 20 21 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 19 def end |
#type ⇒ Object
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
#create_code ⇒ Object
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 |
#index? ⇒ Boolean
62 63 64 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 62 def index? @type == :index end |
#reference? ⇒ Boolean
66 67 68 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 66 def reference? @type == :reference end |
#reference_table_name ⇒ Object
70 71 72 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 70 def reference_table_name @name.pluralize end |
#remove_code ⇒ Object
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 |
#vector? ⇒ Boolean
46 47 48 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 46 def vector? .include?("vector") end |
#with_position? ⇒ Boolean
58 59 60 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 58 def with_position? .include?("with_position") end |
#with_section? ⇒ Boolean
50 51 52 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 50 def with_section? .include?("with_section") end |
#with_weight? ⇒ Boolean
54 55 56 |
# File 'lib/rails/generators/active_groonga/migration/column.rb', line 54 def with_weight? .include?("with_weight") end |