Class: Mongoid::Generators::Base

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/rails/generators/mongoid/mongoid_generator.rb

Overview

:nodoc:

Direct Known Subclasses

MigrationGenerator

Class Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Implement the required interface for Rails::Generators::Migration.



15
16
17
18
19
20
21
22
# File 'lib/rails/generators/mongoid/mongoid_generator.rb', line 15

def self.next_migration_number(dirname) #:nodoc:
  next_migration_number = current_migration_number(dirname) + 1
  if Mongoid.configure.timestamped_migrations
    [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
  else
    "%.3d" % next_migration_number
  end
end

.source_rootObject

A simple redef is fine because rails caches this path on class.inherited mongoid uses @_mongoid_source_root ||=, but that’s not necessary



10
11
12
# File 'lib/rails/generators/mongoid/mongoid_generator.rb', line 10

def self.source_root
  File.expand_path("../../#{base_name}/#{generator_name}/templates", __FILE__)
end