Class: CommerceUnits::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- CommerceUnits::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/commerce_units/install_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Define the next_migration_number method (necessary for the migration_template method to work) Stolen shamelessly from socery gem’s generators.
Instance Method Summary collapse
- #generate_migration ⇒ Object
- #migration_class_name ⇒ Object
- #migration_file_name ⇒ Object
- #migration_name ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
Define the next_migration_number method (necessary for the migration_template method to work) Stolen shamelessly from socery gem’s generators
12 13 14 15 16 17 18 19 |
# File 'lib/generators/commerce_units/install_generator.rb', line 12 def self.next_migration_number(dirname) if ActiveRecord::Base. sleep 1 # make sure each time we get a different timestamp Time.new.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#generate_migration ⇒ Object
21 22 23 |
# File 'lib/generators/commerce_units/install_generator.rb', line 21 def generate_migration migration_template "create_commerce_units_dimensions.rb.erb", "db/migrate/#{migration_file_name}" end |
#migration_class_name ⇒ Object
33 34 35 |
# File 'lib/generators/commerce_units/install_generator.rb', line 33 def migration_class_name migration_name.camelize end |
#migration_file_name ⇒ Object
29 30 31 |
# File 'lib/generators/commerce_units/install_generator.rb', line 29 def migration_file_name "#{migration_name}.rb" end |
#migration_name ⇒ Object
25 26 27 |
# File 'lib/generators/commerce_units/install_generator.rb', line 25 def migration_name "create_commerce_units_dimensions" end |