Class: DeviseTraceableGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- DeviseTraceableGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/devise_traceable/devise_traceable_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/generators/devise_traceable/devise_traceable_generator.rb', line 17 def self.next_migration_number(dirname) if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
.orm_has_migration? ⇒ Boolean
13 14 15 |
# File 'lib/generators/devise_traceable/devise_traceable_generator.rb', line 13 def self.orm_has_migration? Rails::Generators.[:rails][:orm] == :active_record end |
.source_root ⇒ Object
9 10 11 |
# File 'lib/generators/devise_traceable/devise_traceable_generator.rb', line 9 def self.source_root @_devise_source_root ||= File.("../templates", __FILE__) end |
Instance Method Details
#create_migration_file ⇒ Object
44 45 46 |
# File 'lib/generators/devise_traceable/devise_traceable_generator.rb', line 44 def create_migration_file migration_template 'migration.rb', "db/migrate/devise_create_#{name.downcase}_tracings.rb" end |
#invoke_orm_model ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/devise_traceable/devise_traceable_generator.rb', line 28 def invoke_orm_model if model_exists? say "* Model already exists." elsif [:orm].present? invoke "model", ["#{name}Tracing"], :migration => false, :orm => [:orm] unless model_exists? abort "Tried to invoke the model generator for '#{[:orm]}' but could not find it.\n" << "Please create your model by hand before calling `rails g devise_traceable #{name}`." end else abort "Cannot create a devise model because config.generators.orm is blank.\n" << "Please create your model by hand or configure your generators orm before calling `rails g devise_traceable #{name}`." end end |