Module: DockerCompose::Generator::Service::Ports
- Included in:
- DockerCompose::Generator::Service
- Defined in:
- lib/docker-compose/generator/service/ports.rb
Overview
Handles Ports in the docker-compose file
Instance Method Summary collapse
- #add_port(host, container = nil) ⇒ Object
- #drop_port(host, container) ⇒ Object
- #port?(host, container = nil) ⇒ Boolean
Instance Method Details
#add_port(host, container = nil) ⇒ Object
6 7 8 9 10 |
# File 'lib/docker-compose/generator/service/ports.rb', line 6 def add_port(host, container = nil) host = "#{host}:#{container}" if container add_to_array('ports', "#{host}") end |
#drop_port(host, container) ⇒ Object
12 13 14 15 16 |
# File 'lib/docker-compose/generator/service/ports.rb', line 12 def drop_port(host, container) host = "#{host}:#{container}" if container drop_from_array('ports', "#{host}") end |
#port?(host, container = nil) ⇒ Boolean
18 19 20 21 22 23 |
# File 'lib/docker-compose/generator/service/ports.rb', line 18 def port?(host, container = nil) host = "#{host}:#{container}" if container ports = @attrs['ports'] || [] ports.include?("#{host}") end |