-
Notifications
You must be signed in to change notification settings - Fork 68
chore: ensure Options are initialised with defaults #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hi @pbernays thanks for submitting a PR and apologies on getting around to this. I'll try to respond to this inline -- and to be clear, I'm happy to have a conversation around this so that we can improvement the gem.
To provide some history, this gem is a hard fork from One of my initial goals was to make it easier to have isolated functions that were easy to unit test. To get that, most functions now take an
We can get rid of this flag -- you're right, it's not used. I didn't touch it because I wanted the migration from the old gem to this one to be easy.
When I was first doing an audit of the various options, I made these hashes separate so it was clearer what was being used and where. If it doesn't make sense to keep these anymore then it seems fine to remove. |
First off, and this is overdue, I owe you thanks for your gift to open source. I wasn't looking forward to trying to alter the code of the original gem to add the changes in the other PR I put up, but a colleague showed me your 2yo reddit post, and your refactor made it a breeze. So thank you, I appreciate the time and effort you've put in to improve it. Also, I don't believe you owe an apology either, especially when I've been sloppy and haven't corrected the rubocop nitpicks yet.
I'd be happy to be involved in that if you'd like input from collaborators. The tool's always been a set-and-forget kind of deal for me, so I don't have much of a vision for it. But it is very useful and I'd like to contribute to keep it that way, aligned with whatever your plans for it are. Which begs the question, what are your plans?
Thanks for the clarity. It's been a couple of months since I had my head in this code, and I remember having some thoughts about the specs to do with the options, but what they were... ¯\(ツ)/¯. It seems worth removing this change, figuring out what those ideas are to discuss with you, and then follow up if you're in agreement.
Makes perfect sense.
👍 |
Thanks for the kind words :).
This has been my experience as well, although with Rails continuously changing and evolving (a good thing), I've found that updates are needed.
My plan is just to continue for a tool/gem/library like this to exist. I have found it in my past Rails jobs as an improvement in the Rails developer experience. Any and all help is welcome. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good to me -- just 1 question/discussion point
|
||
# Want this to be read only after initializing | ||
def_delegator :@options, :[] | ||
def_delegators :@options, :[], :to_h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd definitely like your thoughts here --
So when I refactored the old gem, I intentionally made Options
read only. In the old gem, it was not clear where options were being set as it was a read-writeable global variable, which made it really hard to debug.
However, we are no longer in the old gem and so it might be less of a concern. Thoughts on keeping it the same versus making it writable by delegating to_h
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. Off the top of my head, I don't believe I wanted this to be writable but a convenience to get a copy. I can't see where I've even used it in the PR, so it might have been something I failed to cleanup after debugging in the console. I think your initial intention is good, I can't think of a reason Options
should need to change after they've been initialized.
I can't see a reason not to load defaults when initialising an Options object (and the comment on line 158/96 suggests it's desired behaviour), so this calls
load_defaults
during init and makes it a private method.Correct me if I'm wrong, but I also can't see a reason to keep the unused
format_bare
flag option given that arbitrary keys are allowed.Removes the
*_OPTIONS_KEYS
constants for being redundant.Tidies up a couple of lines to be clearer.