Skip to content

Commit 04f1f3c

Browse files
authored
fix: change class attribute behavior on endpoint method to work in ruby 3.2+ (#493)
1 parent 9296b88 commit 04f1f3c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/graphiti/resource/links.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ module Overrides
88
def endpoint
99
if (endpoint = super)
1010
endpoint
11-
else
11+
elsif !@__skip_inference
1212
self.endpoint = infer_endpoint
1313
end
1414
end
15+
16+
def endpoint=(value)
17+
# changes introduced in Ruby 3.2 and above require some extra hoops
18+
# to allow .endpoint = nil to work properly
19+
@__skip_inference = value.blank?
20+
super
21+
end
1522
end
1623

1724
included do

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].sort.each { |f| require f }
44
require "pry"
55

6+
require "logger"
67
require "active_model"
78
require "graphiti_spec_helpers/rspec"
89
require "graphiti"

0 commit comments

Comments
 (0)