Class: Atum::Core::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/atum/core/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resources, url) ⇒ Client



29
30
31
32
33
34
# File 'lib/atum/core/client.rb', line 29

def initialize(resources, url)
  @url = url
  resources.each do |name, resource|
    define_singleton_method(name) { resource }
  end
end

Class Method Details

.client_from_schema(api_schema, url, options = {}) ⇒ Client

Create an HTTP client from a schema.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/atum/core/client.rb', line 13

def client_from_schema(api_schema, url, options = {})
  resources = {}
  api_schema.resource_schemas.each do |resource_schema|
    links_hash = {}
    resource_schema.link_schemas.each do |link_schema|
      links_hash[link_schema.name] = Link.new(url, link_schema, options)
    end
    resources[resource_schema.name] = Resource.new(links_hash)
  end

  new(resources, url)
end

Instance Method Details

#inspectObject Also known as: to_s



36
37
38
39
40
# File 'lib/atum/core/client.rb', line 36

def inspect
  url = URI.parse(@url)
  url.password = 'REDACTED' unless url.password.nil?
  "#<Atum::Client url=\"#{url}\">"
end