From 93885eb971dd96a5f2236db366e9c5d5f14552a2 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sat, 15 Jun 2024 13:19:45 +0200 Subject: [PATCH] Remove AM < 6.1 legacy conditional check `parent` was needed to support Active Model < 6.1. Since the minimum required version is now 7.0, the conditional is not needed anymore Ref: rails/rails#34051 Close #12 --- lib/hawk/linker.rb | 2 +- lib/hawk/model/lookup.rb | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/hawk/linker.rb b/lib/hawk/linker.rb index 1452458..1b48d87 100644 --- a/lib/hawk/linker.rb +++ b/lib/hawk/linker.rb @@ -37,7 +37,7 @@ def _monomorphic_resource_accessor(entity, options) def #{entity} return nil unless self.#{key}.present? - @_#{entity} ||= #{respond_to?(:module_parent) ? module_parent : parent}::#{klass}.find(self.#{key}) + @_#{entity} ||= #{module_parent}::#{klass}.find(self.#{key}) end RUBY diff --git a/lib/hawk/model/lookup.rb b/lib/hawk/model/lookup.rb index 8848d3c..36c9dd6 100644 --- a/lib/hawk/model/lookup.rb +++ b/lib/hawk/model/lookup.rb @@ -66,7 +66,7 @@ def look_up_model_class(name, scope) return self_constant end - scope_parent = scope.respond_to?(:module_parent) ? scope.module_parent : scope.parent + scope_parent = scope.module_parent if (parent_constant = look_up_constant_in(name, scope_parent)) return parent_constant @@ -82,11 +82,7 @@ def look_up_model_class(name, scope) end def look_up_constant_in(name, scope) - if scope.respond_to?(:module_parent) - scope.module_parent.const_get(name) - else - scope.parent.const_get(name) - end + scope.module_parent.const_get(name) rescue NameError nil end