Created by: gracewashere
Fixes #310 (closed)
Problem:
Rails provides a way to undo the effects of generators,
by running the command rails destroy GENERATOR_NAME
.
With the way that we had set up our hierarchy of generators, Rails did not know how to undo the effects of sub-generators.
For example, with the administrate:views
generator,
we were calling Rails::Generators.invoke("administrate:views:index")
.
Whether the generator was run with the generate
or destroy
command
did not make a difference -
the index generator would always be invoked
as if it were run with generate
.
Solution:
Rails generators use the @behavior
instance variable to keep track of
how the generator was run.
This variable can be either :invoke
or :revoke
.
Pass this variable as an option to the sub-generators to ensure they have the same behavior as the parent.
Minor changes:
Extract Administrate::GeneratorHelpers
to store common
generator-related methods.