class Pushme::Generators::InstallGenerator
Public Class Methods
next_migration_number(_path)
click to toggle source
Implement the required interface for Rails::Generators::Migration
# File lib/generators/pushme/install_generator.rb, line 29 def self.next_migration_number(_path) Time.now.utc.strftime('%Y%m%d%H%M%S') end
Public Instance Methods
copy_migration()
click to toggle source
# File lib/generators/pushme/install_generator.rb, line 15 def copy_migration file_name = 'add_devices' migration_name = "#{file_name}_to_#{table_name}.rb" if self.class.migration_exists?('db/migrate', migration_name) say_status('skipped', "Migration #{migration_name} already exists") else migration_template "#{file_name}.rb", "db/migrate/#{migration_name}", migration_version: migration_version, table_name: table_name end end
Private Instance Methods
migration_version()
click to toggle source
# File lib/generators/pushme/install_generator.rb, line 39 def migration_version "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if rails5? end
rails5?()
click to toggle source
# File lib/generators/pushme/install_generator.rb, line 35 def rails5? Rails.version.start_with? '5' end
table_name()
click to toggle source
# File lib/generators/pushme/install_generator.rb, line 43 def table_name @table_name ||= Pushme.table_name end