Class: Atum::Core::Client
- Inherits:
-
Object
- Object
- Atum::Core::Client
- Defined in:
- lib/atum/core/client.rb
Class Method Summary collapse
-
.client_from_schema(api_schema, url, options = {}) ⇒ Client
Create an HTTP client from a schema.
Instance Method Summary collapse
-
#initialize(resources, url) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object (also: #to_s)
Constructor Details
#initialize(resources, url) ⇒ Client
Returns a new instance of 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, = {}) 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, ) end resources[resource_schema.name] = Resource.new(links_hash) end new(resources, url) end |
Instance Method Details
#inspect ⇒ Object 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 |