Class: Nrb::Commands::Destroy

Inherits:
Resource show all
Defined in:
lib/nrb/commands/destroy.rb

Overview

This command destroys a resource, and if it is a model, it also destroys the correspnding create migration file.

Instance Method Summary collapse

Methods inherited from Resource

#ensure_valid_resource, valid_resources

Methods inherited from Inside

#ensure_inside_root

Methods inherited from Base

#opts, source_root

Instance Method Details

#destroy_migrationObject



12
13
14
15
16
17
# File 'lib/nrb/commands/destroy.rb', line 12

def destroy_migration
  return false unless resource == 'model'
  prefix = 'db/migrate/*_create_'
  migration_file = Dir["#{prefix}#{name.underscore.pluralize}.rb"].first
  remove_file(migration_file, opts) if migration_file
end

#destroy_resourceObject



8
9
10
# File 'lib/nrb/commands/destroy.rb', line 8

def destroy_resource
  remove_file target("#{name.underscore}.rb"), opts
end