Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve

## [Unreleased]

### Changed

- Performance improvements for building a hash from Dry::Struct when it contains nested structs (found by @rpeng in #200)


## [1.8.0] - 2025-03-09

Expand Down
6 changes: 3 additions & 3 deletions lib/dry/struct/hashify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ class Struct
# Helper for {Struct#to_hash} implementation
module Hashify
# Converts value to hash recursively
# @param [#to_hash, #map, Object] value
# @param [#to_hash, #to_ary, Object] value
# @return [Hash, Array]
def self.[](value)
if value.is_a?(Struct)
value.to_h.transform_values { self[_1] }
if value.is_a?(::Dry::Struct)
value.to_h
elsif value.respond_to?(:to_hash)
value.to_hash.transform_values { self[_1] }
elsif value.respond_to?(:to_ary)
Expand Down