Closed tmfnll closed 4 years ago
Thank you for the pull request. I think this solution is too complex just to allow nested no_commands
. Can you explain why you need nested no_commands
?
Hello, I have been working on refactoring some scripts for a Rails application and wanted to make use of the ActiveModel
validation API. So I included the ActiveModel::Validations
module which created the nested no_commands
via an attr_reader
.
Allow for nested
no_commands
blocks. 🌈Background
In certain circumstances we may wish to nest
no_commands
blocks.However, since when exiting the
no_commands
block the@no_commands
instance var is reset tofalse
, we get unexpected behaviour.For example, this will show warnings stating that the method
foo
is missing usage and a description:This particular example is trivially solved but things get more difficult when, say, including modules.
Solution
This change uses a
NestedContext
object to track the depth of theno_command
blocks and ensure that we only start creating commands again once we've left all of them.Comments
NestedContext