Class: Hanami::Commands::Generate::Migration

Inherits:
Abstract show all
Defined in:
lib/hanami/commands/generate/migration.rb

Constant Summary collapse

TIMESTAMP_FORMAT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Examples:

20150612160502

Since:

  • 0.6.0

'%Y%m%d%H%M%S'.freeze
FILENAME_PATTERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Examples:

20150612160502_create_books.rb

Since:

  • 0.6.0

'%{timestamp}_%{name}.rb'.freeze

Instance Attribute Summary collapse

Attributes inherited from Abstract

#options, #target_path

Instance Method Summary collapse

Methods inherited from Abstract

#template_source_path

Methods included from Generators::Generatable

#add_mapping, #argument_blank?, #destroy, #generator, #post_process_templates, #process_templates, #start, #target_path, #template_options, #template_source_path

Methods inherited from Command

inherited

Constructor Details

#initialize(options, name) ⇒ Migration

Returns a new instance of Migration.



25
26
27
28
29
30
31
32
33
# File 'lib/hanami/commands/generate/migration.rb', line 25

def initialize(options, name)
  super(options)

  @name = name
  @underscored_name = Utils::String.new(@name).underscore

  Components.resolve('model.configuration')
  assert_migration_name!
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/hanami/commands/generate/migration.rb', line 9

def name
  @name
end

#underscored_nameObject (readonly)

Returns the value of attribute underscored_name.



9
10
11
# File 'lib/hanami/commands/generate/migration.rb', line 9

def underscored_name
  @underscored_name
end

Instance Method Details

#map_templatesObject



35
36
37
# File 'lib/hanami/commands/generate/migration.rb', line 35

def map_templates
  add_mapping('migration.rb.tt', destination_path)
end