From ab6bc64709bba13c234e0dfebe78cd37323c038f Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:37:25 +0100 Subject: [PATCH] fix: Upgrade for compatibility with Ruby 3 (#45) --- .github/workflows/tests.yaml | 2 +- lib/openactive/concerns/json_ld_serializable.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5a4b60ef..6b4cf5ea 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['2.6', '2.7'] + ruby-version: ['2.7', '3.0', '3.1'] steps: - uses: actions/checkout@v2 diff --git a/lib/openactive/concerns/json_ld_serializable.rb b/lib/openactive/concerns/json_ld_serializable.rb index eb34bc2a..d17ab852 100644 --- a/lib/openactive/concerns/json_ld_serializable.rb +++ b/lib/openactive/concerns/json_ld_serializable.rb @@ -25,16 +25,18 @@ def property(field, as:) def values data = {} - self.class.properties.each do |key, field:| - data[key] = send(field) + self.class.properties.each do |key, field| + field_value = field[:field] + data[key] = send(field_value) end data end def to_h data = {} - self.class.properties.each do |_key, field:| - data[field] = send(field) + self.class.properties.each do |_key, field| + field_value = field[:field] + data[field_value] = send(field_value) end data end