Class: EavMigrationGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/generators/eav_migration/eav_migration.rb

Instance Method Summary collapse

Instance Method Details

#create_eav_migrationObject


12
13
14
15
# File 'lib/generators/eav_migration/eav_migration.rb', line 12

def create_eav_migration
  p name
  migration_template "eav_migration.erb", "db/migrate/#{migration_file_name}.rb"
end

#migration_file_nameObject


17
18
19
# File 'lib/generators/eav_migration/eav_migration.rb', line 17

def migration_file_name
  "create_" + table_name
end

#migration_nameObject


21
22
23
# File 'lib/generators/eav_migration/eav_migration.rb', line 21

def migration_name
  migration_file_name.camelize
end

#model_association_nameObject


33
34
35
# File 'lib/generators/eav_migration/eav_migration.rb', line 33

def model_association_name
  model_name.underscore.gsub(/\//,'_')
end

#model_nameObject


29
30
31
# File 'lib/generators/eav_migration/eav_migration.rb', line 29

def model_name
  name
end

#table_nameObject


25
26
27
# File 'lib/generators/eav_migration/eav_migration.rb', line 25

def table_name
  custom_table_name || "#{name}_#{hash_name}".underscore.gsub(/\//, '_')
end