Skip to content

Conversation

@shioyama
Copy link
Member

No description provided.

@shioyama shioyama force-pushed the shioyama/order_reporter_eagerly_open_file branch from 30544ba to e37158d Compare August 25, 2025 07:43
Copy link
Contributor

@davidstosik davidstosik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the uneasy feeling that opening the file too early might cause other issues, but I can't pinpoint a proper reason.
This might just be fine as-is. 👍🏻

Oh here's one: are there scenarios in which OrderReporter would be initialized (meaning it will open the file), but #report wont be called (meaning it wouldn't close it)?

Comment on lines 26 to 27
attr_reader :file
private :file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works, but I feel like we rarely see it written that way.
Why not this? 👇🏻

Suggested change
attr_reader :file
private :file
private
attr_reader :file

def initialize(options = {})
@path = options.delete(:path)
@file = nil
@file ||= File.open(@path, 'a+')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're initializing, there's no scenario in which @file is already set at this point?

Suggested change
@file ||= File.open(@path, 'a+')
@file = File.open(@path, 'a+')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep got that one thanks

@shioyama shioyama force-pushed the shioyama/order_reporter_eagerly_open_file branch from e37158d to 8daad48 Compare August 25, 2025 07:45
@shioyama shioyama closed this Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants