Skip to content

Commit

Permalink
Check if resource_type is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunwei Wang committed Nov 17, 2024
1 parent 2a99bfa commit 7293994
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/fhir_client/ext/reference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Reference
include FHIR::ReferenceExtras

def resource_class
FHIR.const_get(resource_type) unless contained?
FHIR.const_get(resource_type) unless contained? || resource_type.nil?
end
end
end
Expand All @@ -101,7 +101,7 @@ def resource_class

module FHIR
module STU3
class Reference
class Reference
include FHIR::ReferenceExtras

def resource_class
Expand Down
5 changes: 5 additions & 0 deletions test/unit/reference_extras_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def test_reference_klass_dstu2
assert r.resource_class == FHIR::DSTU2::Patient
end

def test_reference_klass_empty
r = FHIR::Reference.new({'display': 'abc'})
assert r.resource_class.nil?
end

def test_relative
r = FHIR::Reference.new({'reference': 'Patient/foo'})
assert r.relative?
Expand Down

0 comments on commit 7293994

Please sign in to comment.