Class: ExtensionMigrationGenerator

Inherits:
Rails::Generator::NamedBase
  • Object
show all
Defined in:
lib/generators/extension_migration/extension_migration_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runtime_args, runtime_options = {}) ⇒ ExtensionMigrationGenerator

Returns a new instance of ExtensionMigrationGenerator.



7
8
9
10
11
12
# File 'lib/generators/extension_migration/extension_migration_generator.rb', line 7

def initialize(runtime_args, runtime_options = {})
  super
  @extension_file_name = "#{file_name}_extension"
  @extension_path = "vendor/extensions/#{file_name}"
  @migration_name = runtime_args[1]
end

Instance Attribute Details

#extension_file_nameObject (readonly)

Returns the value of attribute extension_file_name.



5
6
7
# File 'lib/generators/extension_migration/extension_migration_generator.rb', line 5

def extension_file_name
  @extension_file_name
end

#extension_pathObject (readonly)

Returns the value of attribute extension_path.



5
6
7
# File 'lib/generators/extension_migration/extension_migration_generator.rb', line 5

def extension_path
  @extension_path
end

Instance Method Details

#attributesObject

overload the super method which was causing problems for some unknown reason (too lazy to debug properly)



15
16
17
# File 'lib/generators/extension_migration/extension_migration_generator.rb', line 15

def attributes
  []
end


19
20
21
# File 'lib/generators/extension_migration/extension_migration_generator.rb', line 19

def banner
  "Usage: #{$0} extension_migration ExtensionName MigrationName [options]"
end

#manifestObject



23
24
25
26
27
28
29
30
# File 'lib/generators/extension_migration/extension_migration_generator.rb', line 23

def manifest    
  record do |m|
    m.migration_template 'migration.rb', 
                         "#{extension_path}/db/migrate", 
                         :assigns => {:migration_name => @migration_name},
                         :migration_file_name => @migration_name.underscore
  end
end