Class: Mobility::BackendGenerators::Base

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
ActiveRecord::Generators::Migration, ActiveRecordMigrationCompatibility
Defined in:
lib/rails/generators/mobility/backend_generators/base.rb

Direct Known Subclasses

ColumnBackend, TableBackend

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveRecordMigrationCompatibility

#activerecord_migration_class

Class Method Details

.next_migration_number(dirname) ⇒ Object



19
20
21
# File 'lib/rails/generators/mobility/backend_generators/base.rb', line 19

def self.next_migration_number(dirname)
  ::ActiveRecord::Generators::Base.next_migration_number(dirname)
end

Instance Method Details

#backendObject



23
24
25
# File 'lib/rails/generators/mobility/backend_generators/base.rb', line 23

def backend
  self.class.name.split('::').last.gsub(/Backend$/,'').underscore
end

#create_migration_fileObject



11
12
13
14
15
16
17
# File 'lib/rails/generators/mobility/backend_generators/base.rb', line 11

def create_migration_file
  if behavior == :invoke && self.class.migration_exists?(migration_dir, migration_file)
    ::Kernel.warn "Migration already exists: #{migration_file}"
  else
    migration_template "#{template}.rb", "db/migrate/#{migration_file}.rb"
  end
end