Move site and collections console commands to locals #853
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a 馃悰 bug fix.
Summary
Move the
site
andcollections
console commands to be local variables in the IRB shell.Context
Console methods have precedence over Ruby methods with the same name. This means that any method name or local variable will be clobbered by the IRB commands
site
andcollections
. This presents an issue when using the IRB or Pry object navigation features, e.g.In this example, I've tried to execute
Bridgetown::Site#render
after setting the IRB workspace tosite
. This results in aSystemStackError
because when callingcollections
on this line, thecollections
IRB command is executed instead of thecollections
instance method onsite
.This PR moves
site
andcollections
to local variables that are passed into the main IRB workspace as a binding. This does mean that over the course of an IRB session, a user is free to initializesite
orcollections
to something else. The upshot is that there's no longer a risk of clobbering these method names.