Class: Bigrig::Container
- Defined in:
- lib/bigrig/models/container.rb
Constant Summary collapse
- ARRAY_ATTRS =
:volumes_from, :links, :hosts, :volumes
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#links ⇒ Object
Returns the value of attribute links.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#ports ⇒ Object
Returns the value of attribute ports.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#scan ⇒ Object
Returns the value of attribute scan.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#volumes ⇒ Object
Returns the value of attribute volumes.
-
#volumes_from ⇒ Object
Returns the value of attribute volumes_from.
Class Method Summary collapse
Instance Method Summary collapse
- #dependencies ⇒ Object
-
#initialize(*opts) ⇒ Container
constructor
A new instance of Container.
Constructor Details
#initialize(*opts) ⇒ Container
Returns a new instance of Container.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bigrig/models/container.rb', line 25 def initialize(*opts) super @env ||= {} @ports ||= [] ARRAY_ATTRS.map { |a| "@#{a}" }.each do |attr| instance_variable_get(attr) || instance_variable_set(attr, []) end # Yes rubocop, I know this is a very stupid thing to do @env = Hash[*@env.map { |k, v| [k, eval("\"#{v}\"")] }.flatten] # rubocop:disable Lint/Eval end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def env @env end |
#hosts ⇒ Object
Returns the value of attribute hosts.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def hosts @hosts end |
#links ⇒ Object
Returns the value of attribute links.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def links @links end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def path @path end |
#ports ⇒ Object
Returns the value of attribute ports.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def ports @ports end |
#repo ⇒ Object
Returns the value of attribute repo.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def repo @repo end |
#scan ⇒ Object
Returns the value of attribute scan.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def scan @scan end |
#tag ⇒ Object
Returns the value of attribute tag.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def tag @tag end |
#volumes ⇒ Object
Returns the value of attribute volumes.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def volumes @volumes end |
#volumes_from ⇒ Object
Returns the value of attribute volumes_from.
4 5 6 |
# File 'lib/bigrig/models/container.rb', line 4 def volumes_from @volumes_from end |
Class Method Details
.from_json(name, json) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/bigrig/models/container.rb', line 8 def from_json(name, json) opts = [:env, :path, :ports, :tag, :repo, :scan].each_with_object(name: name) do |e, o| o[e] = json.send :[], e.to_s end ARRAY_ATTRS.each { |x| opts[x] = as_array json[x.to_s] } Container.new opts end |
Instance Method Details
#dependencies ⇒ Object
38 39 40 |
# File 'lib/bigrig/models/container.rb', line 38 def dependencies volumes_from + links.map { |l| l.split(':').first } end |