class QyWechat::Generators::MigrationGenerator

Public Instance Methods

create_migration_file() click to toggle source
# File lib/generators/qy_wechat/migration_generator.rb, line 9
def create_migration_file
  if !migration_exists?(table_name)
    migration_template "add_qy_wechat_columns.rb", "db/migrate/add_qy_wechat_columns_to_#{plural_name}.rb"
  end
end

Private Instance Methods

migration_exists?(table_name) click to toggle source
# File lib/generators/qy_wechat/migration_generator.rb, line 25
def migration_exists?(table_name)
  Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_add_qy_wechat_columns_to_#{table_name}.rb/).first
end
migration_path() click to toggle source
# File lib/generators/qy_wechat/migration_generator.rb, line 29
def migration_path
  @migration_path ||= File.join("db", "migrate")
end
model_exists?() click to toggle source
# File lib/generators/qy_wechat/migration_generator.rb, line 17
def model_exists?
  File.exists?(File.join(destination_root, model_path))
end
model_path() click to toggle source
# File lib/generators/qy_wechat/migration_generator.rb, line 21
def model_path
  @model_path ||= File.join("app", "models", "#{file_path}.rb")
end