Class: Deimos::Generators::DbPollerGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Deimos::Generators::DbPollerGenerator
- Extended by:
- ActiveRecord::Generators::Migration
- Includes:
- ActiveRecord::Generators::Migration, Rails::Generators::Migration
- Defined in:
- lib/generators/deimos/db_poller_generator.rb
Overview
Generate the database backend migration.
Instance Method Summary collapse
- #db_migrate_path ⇒ String
-
#generate ⇒ Object
Main method to create all the necessary files.
- #migration_version ⇒ String
Instance Method Details
#db_migrate_path ⇒ String
27 28 29 30 31 32 33 34 |
# File 'lib/generators/deimos/db_poller_generator.rb', line 27 def db_migrate_path if defined?(Rails.application) && Rails.application paths = Rails.application.config.paths['db/migrate'] paths.respond_to?(:to_ary) ? paths.to_ary.first : paths.to_a.first else 'db/migrate' end end |
#generate ⇒ Object
Main method to create all the necessary files
37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/deimos/db_poller_generator.rb', line 37 def generate if Rails.version < '4' migration_template('rails3_migration', "#{db_migrate_path}/create_db_poller.rb") else migration_template('migration', "#{db_migrate_path}/create_db_poller.rb") end end |
#migration_version ⇒ String
20 21 22 23 24 |
# File 'lib/generators/deimos/db_poller_generator.rb', line 20 def migration_version "[#{ActiveRecord::Migration.current_version}]" rescue StandardError '' end |