Skip to content

Commit

Permalink
Merge pull request #53 from javierjulio/patch-1
Browse files Browse the repository at this point in the history
Remove OpenStruct usage with Struct replacement
  • Loading branch information
ilyazub committed Apr 16, 2024
2 parents 7031210 + a3220a1 commit 6ada9df
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
1 change: 0 additions & 1 deletion lib/turbo_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require "open3"
require "fileutils"
require "ostruct"
require "json"
require "rspec"

Expand Down
4 changes: 1 addition & 3 deletions lib/utils/hash_extension.rb
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
end
end

0 comments on commit 6ada9df

Please sign in to comment.