-
Notifications
You must be signed in to change notification settings - Fork 33
Remove OpenStruct usage with Struct replacement #53
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |
|
|
||
| require "open3" | ||
| require "fileutils" | ||
| require "ostruct" | ||
| require "json" | ||
| require "rspec" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,7 @@ | ||
| module CoreExtensions | ||
| refine Hash do | ||
| def to_struct | ||
| OpenStruct.new(self.each_with_object({}) do |(key, val), acc| | ||
| acc[key] = val.is_a?(Hash) ? val.to_struct : val | ||
| end) | ||
| Struct.new(*self.keys).new(*self.values.map { |value| value.is_a?(Hash) ? value.to_struct : value }) | ||
| end | ||
|
Comment on lines
3
to
5
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if @smileart Do you remember why |
||
| end | ||
| end | ||
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.
jsongem is usedTurboTests::JsonRowsFormatter#JsonRowsFormatterto provideto_jsonmethod, similarly to theRSpec::Core::Formatters::JsonFormatter#closemethod.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.
Oh, indeed! Sounds like we still need json then!