From daf19088c29f85082fcebbc8728a71d0dc3d29b2 Mon Sep 17 00:00:00 2001 From: Jared White Date: Thu, 18 Apr 2024 22:20:45 -0700 Subject: [PATCH] Support Ruby 3+ pattern matching for Collection and Resource::Base --- bridgetown-core/lib/bridgetown-core/collection.rb | 2 ++ bridgetown-core/lib/bridgetown-core/resource/base.rb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/bridgetown-core/lib/bridgetown-core/collection.rb b/bridgetown-core/lib/bridgetown-core/collection.rb index 674c349c2..39c8dd002 100644 --- a/bridgetown-core/lib/bridgetown-core/collection.rb +++ b/bridgetown-core/lib/bridgetown-core/collection.rb @@ -54,6 +54,8 @@ def resources_by_relative_url # Iterate over Resources, support Enumerable def each(...) = resources.each(...) + def deconstruct = resources.deconstruct + # Fetch the static files in this collection. # Defaults to an empty array if no static files have been read in. # diff --git a/bridgetown-core/lib/bridgetown-core/resource/base.rb b/bridgetown-core/lib/bridgetown-core/resource/base.rb index 5344aa285..ea1ec1403 100644 --- a/bridgetown-core/lib/bridgetown-core/resource/base.rb +++ b/bridgetown-core/lib/bridgetown-core/resource/base.rb @@ -343,6 +343,10 @@ def previous_resource alias_method :previous_doc, :previous_resource alias_method :previous, :previous_resource + def deconstruct_keys(...) + @data.value.deconstruct_keys(...) + end + def mark_for_fast_refresh! @fast_refresh_order = site.fast_refresh_ordering site.fast_refresh_ordering += 1