Module: Docker::Model
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
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Object
Creates a new Model with the specified id and Connection.
- #to_s ⇒ Object
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/docker/model.rb', line 6 def connection @connection end |
#id ⇒ Object (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( = {}) if ([:connection] ||= Docker.connection).is_a?(Docker::Connection) @id, @connection = [:id], [:connection] else raise ArgumentError, 'Expected a Docker::Connection.' end end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/docker/model.rb', line 27 def to_s "#{self.class.name} { :id => #{id}, :connection => #{connection} }" end |