class Inferno::DSL::FHIRClientBuilder
DSL
for configuring FHIR clients
Attributes
runnable[RW]
Public Instance Methods
bearer_token(bearer_token = nil)
click to toggle source
Define the bearer token for a client. A string or symbol can be provided. A string is interpreted as a token. A symbol is interpreted as the name of an input to the Runnable
.
@param bearer_token
[String, Symbol] @return [void]
# File lib/inferno/dsl/fhir_client_builder.rb, line 42 def bearer_token(bearer_token = nil) @bearer_token ||= if bearer_token.is_a? Symbol runnable.send(bearer_token) else bearer_token end end
build(runnable, block)
click to toggle source
@api private
# File lib/inferno/dsl/fhir_client_builder.rb, line 10 def build(runnable, block) self.runnable = runnable instance_exec(self, &block) FHIR::Client.new(url).tap do |client| client.additional_headers = headers if headers client.default_json client.set_bearer_token bearer_token if bearer_token end end
headers(headers = nil)
click to toggle source
Define custom headers for a client
@param headers [Hash] @return [void]
# File lib/inferno/dsl/fhir_client_builder.rb, line 55 def headers(headers = nil) @headers ||= headers end
method_missing(name, *args, &block)
click to toggle source
@api private
Calls superclass method
# File lib/inferno/dsl/fhir_client_builder.rb, line 60 def method_missing(name, *args, &block) return runnable.call(name, *args, &block) if runnable.respond_to? name super end
respond_to_missing?(name)
click to toggle source
@api private
Calls superclass method
# File lib/inferno/dsl/fhir_client_builder.rb, line 67 def respond_to_missing?(name) runnable.respond_to?(name) || super end
url(url = nil)
click to toggle source
Define the base FHIR url for a client. A string or symbol can be provided. A string is interpreted as a url. A symbol is interpreted as the name of an input to the Runnable
.
@param url [String, Symbol] @return [void]
# File lib/inferno/dsl/fhir_client_builder.rb, line 27 def url(url = nil) @url ||= if url.is_a? Symbol runnable.send(url) else url end end