Class: Lotus::Commands::Generate::Migration

Inherits:
Abstract
  • Object
show all
Defined in:
lib/lotus/commands/generate/migration.rb

Overview

Since:

  • 0.1.0

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, #destroy, #generator, #post_process_templates, #process_templates, #start, #target_path, #template_options, #template_source_path

Constructor Details

#initialize(options, name) ⇒ Migration

Returns a new instance of Migration.

Since:

  • 0.1.0



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

def initialize(options, name)
  super(options)

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

  environment.require_application_environment
  assert_migration_name!
end

Instance Attribute Details

#nameObject (readonly)

Since:

  • 0.1.0



8
9
10
# File 'lib/lotus/commands/generate/migration.rb', line 8

def name
  @name
end

#underscored_nameObject (readonly)

Since:

  • 0.1.0



8
9
10
# File 'lib/lotus/commands/generate/migration.rb', line 8

def underscored_name
  @underscored_name
end

Instance Method Details

#map_templatesObject

Since:

  • 0.1.0



34
35
36
# File 'lib/lotus/commands/generate/migration.rb', line 34

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