Class: Nrb::Commands::Destroy

Inherits:
InsideGroup
  • Object
show all
Defined in:
lib/nrb/commands/destroy.rb

Instance Method Summary collapse

Methods inherited from InsideGroup

#check_inside?, desc_with_warning, source_root, warning

Instance Method Details

#generate_resourceObject



25
26
27
28
29
30
31
32
33
# File 'lib/nrb/commands/destroy.rb', line 25

def generate_resource
  remove_file target("#{name.underscore}.rb")

  # Also remove the *_create_resource migration
  if resource == 'model'
    migration_file = Dir["db/migrate/*create_#{name.underscore.pluralize}.rb"].first
    remove_file migration_file if migration_file
  end
end

#valid_resource?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/nrb/commands/destroy.rb', line 18

def valid_resource?
  valid_resources = Nrb.config.directories.map(&:singularize)
  return if valid_resources.include? resource
  say "RESOURCE must be one of: #{valid_resources.join(', ')}."
  exit
end