Class: Docker::API::Base
- Inherits:
-
Object
- Object
- Docker::API::Base
- Defined in:
- lib/docker/api/base.rb
Overview
Base class to provide general methods, helpers and implementations accross classes.
Direct Known Subclasses
Config, Container, Exec, Image, Network, Node, Plugin, Secret, Service, Swarm, System, Task, Volume
Instance Attribute Summary collapse
-
#api_version ⇒ Object
Returns the value of attribute api_version.
Instance Method Summary collapse
-
#initialize(connection = nil) ⇒ Base
constructor
Create new object and sets the validation to happen automatically when method parameters include “params” or “body”.
-
#request(params) ⇒ Object
Call an Excon request and returns a Docker::API::Response object.
Constructor Details
#initialize(connection = nil) ⇒ Base
Create new object and sets the validation to happen automatically when method parameters include “params” or “body”.
26 27 28 29 30 |
# File 'lib/docker/api/base.rb', line 26 def initialize connection = nil raise StandardError.new("Expected connection to be a Docker::API::Connection class") if connection != nil && !connection.is_a?(Docker::API::Connection) @connection = connection || Docker::API::Connection.new @api_version = Docker::API.default_api_version end |
Instance Attribute Details
#api_version ⇒ Object
Returns the value of attribute api_version.
4 5 6 |
# File 'lib/docker/api/base.rb', line 4 def api_version @api_version end |
Instance Method Details
#request(params) ⇒ Object
Call an Excon request and returns a Docker::API::Response object.
14 15 16 17 18 19 20 |
# File 'lib/docker/api/base.rb', line 14 def request params params[:path] = build_path(params[:path], params[:params] ||= {}) response = Docker::API::Response.new(@connection.excon.request(params).data) response.request_params = params p response if Docker::API.print_response_to_stdout response end |