Class: Nandi::IndexGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Nandi::IndexGenerator
- Includes:
- Formatting
- Defined in:
- lib/generators/nandi/index/index_generator.rb
Instance Attribute Summary collapse
-
#add_index_name ⇒ Object
readonly
Returns the value of attribute add_index_name.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#index_name ⇒ Object
readonly
Returns the value of attribute index_name.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
Methods included from Formatting
Instance Attribute Details
#add_index_name ⇒ Object (readonly)
Returns the value of attribute add_index_name.
16 17 18 |
# File 'lib/generators/nandi/index/index_generator.rb', line 16 def add_index_name @add_index_name end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
16 17 18 |
# File 'lib/generators/nandi/index/index_generator.rb', line 16 def columns @columns end |
#index_name ⇒ Object (readonly)
Returns the value of attribute index_name.
16 17 18 |
# File 'lib/generators/nandi/index/index_generator.rb', line 16 def index_name @index_name end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
16 17 18 |
# File 'lib/generators/nandi/index/index_generator.rb', line 16 def table @table end |
Instance Method Details
#add_index ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/nandi/index/index_generator.rb', line 18 def add_index tables_list = tables.split(",") @columns = columns.split(",") tables_list.each_with_index do |table, idx| next if table.empty? @table = table.to_sym @add_index_name = "add_index_on_#{columns.join('_')}_to_#{table}" @index_name = ( override_index_name || "idx_#{table}_on_#{columns.join('_')}" ).to_sym template( "add_index.rb", "#{base_path}/#{(idx)}_#{add_index_name}.rb", ) end end |