diff --git a/lib/fhir_client/ext/model.rb b/lib/fhir_client/ext/model.rb index e96d602f..51eb82bb 100644 --- a/lib/fhir_client/ext/model.rb +++ b/lib/fhir_client/ext/model.rb @@ -1,15 +1,15 @@ module FHIR class Model class << self - cattr_accessor :client + cattr_accessor :client, instance_accessor: false end def client - @client || self.class.client + @@client || self.class.client end def client=(client) - @client = client + @@client = client # Ensure the client-setting cascades to all child models instance_values.each do |_key, values| diff --git a/lib/fhir_client/sections/crud.rb b/lib/fhir_client/sections/crud.rb index 5ac23b72..686c902a 100644 --- a/lib/fhir_client/sections/crud.rb +++ b/lib/fhir_client/sections/crud.rb @@ -154,12 +154,13 @@ def base_create(resource, options, format) else resource # just send back the submitted resource end + resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link) else - resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.response[:headers]['location']) + resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link) reply.resource = resource # don't know the content type, so return the resource provided end else - resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.response[:headers]['location']) + resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link) reply.resource = resource # just send back the submitted resource end reply.resource.client = self