Skip to content

Commit

Permalink
Remove legacy conditional check
Browse files Browse the repository at this point in the history
`parent` was needed to support Active Model 5. Since the minimum
required version is not 7, the conditional is not needed anymore

Close #12
  • Loading branch information
tagliala committed Jun 15, 2024
1 parent bf98204 commit 06fe1e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/hawk/linker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions lib/hawk/model/lookup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 06fe1e4

Please sign in to comment.