Module: Docker::Model

Includes:
Error
Included in:
Container, Image
Defined in:
lib/docker/model.rb

Overview

This module is intended to be used as a Mixin for all objects exposed by the Remote API. Currently, these are limited to Containers and Images.

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/docker/model.rb', line 6

def connection
  @connection
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/docker/model.rb', line 6

def id
  @id
end

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/docker/model.rb', line 8

def self.included(base)
  base.class_eval do
    extend ClassMethods
    private_class_method :new, :request, :set_create_request,
                         :set_resource_prefix
  end
end

Instance Method Details

#initialize(options = {}) ⇒ Object

Creates a new Model with the specified id and Connection. If a Connection is specified and it is not a Docker::Connection, a Docker::Error::ArgumentError is raised.



19
20
21
22
23
24
25
# File 'lib/docker/model.rb', line 19

def initialize(options = {})
  if (options[:connection] ||= Docker.connection).is_a?(Docker::Connection)
    @id, @connection = options[:id], options[:connection]
  else
    raise ArgumentError, 'Expected a Docker::Connection.'
  end
end

#to_sObject



27
28
29
# File 'lib/docker/model.rb', line 27

def to_s
  "#{self.class.name} { :id => #{id}, :connection => #{connection} }"
end