Skip to content

Commit

Permalink
This fixes fhir-crucible#34 and an occassional bug extracting the id …
Browse files Browse the repository at this point in the history
…on a create operation.
  • Loading branch information
jawalonoski committed Oct 12, 2016
1 parent 7e6f9ed commit e92c5a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/fhir_client/ext/model.rb
Original file line number Diff line number Diff line change
@@ -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|
Expand Down
5 changes: 3 additions & 2 deletions lib/fhir_client/sections/crud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e92c5a3

Please sign in to comment.